在html字符串上分割图像标签 [英] Split a image tag on html string
本文介绍了在html字符串上分割图像标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
代码:
<div id="start">
<p>"hi split html string"<p><br>"now"
<img class="image1" src="some src" master_src="some src" master_w="400" master_h="320">
"second tag is coming"<br><img class="image2" src="some src" master_src="some src" master_w="400" master_h="320"><h1>end here</h1>
</div>
输出:
<p>"hi split html string"<p><br>"now" , "second tag is coming"<br> , <h1>end here</h1>
我如何实现这一目标?为了使用split函数(或其他更好的方法),此图像类的正则表达式可能是什么?请给我演示
How can i achieve this ouput? what could be regex expression fot this image class in order to use split function(or any better way)?Please give me a demo
推荐答案
为什么多次问同一个问题?
您在这里回答
why are you askying the same question multiple time?
Here is you answer
$('#start').find('img').each(function(index){
var split_text = $(this).html().split(/<img[^>]*>/)[index];
alert(split_text)
});
这篇关于在html字符串上分割图像标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文