[英]extract text between string - javascript
I have a string: 我有一个字符串:
<iframe src="keep-url" width="125" height="290" frameborder="0" scrolling="no"></iframe>
I want to remove all except: 我要删除所有以下内容:
keep-url
and using Javascript, jquery, with jsfiddle 并通过jsfiddle使用Javascript,jquery
Thank you. 谢谢。
You don't need to extract text from the string, you can get the src
attribute from the element: 您无需从字符串中提取文本,可以从元素获取
src
属性:
var src = $('<iframe src="keep-url" width="125" height="290" frameborder="0" scrolling="no"></iframe>').attr('src'); console.log(src);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
使用jQuery创建元素(不添加到文档中)并获取属性:
$src = $(theString).attr('src');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.