在html文本中搜索字符串

编程入门 行业动态 更新时间:2024-10-26 23:38:26
本文介绍了在html文本中搜索字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨所有 i在运行时有字符串包含这样的html标签

< tr > < td > < br > < div style = border:1px solid#999999; width:400px; float:left; margin-removed50px; > < p style = width:400px; > < br > < img src = images / img1.gif style = float:right; > < / div > < div class = clear style = height:5px; > < / div > < table class = normaltable 样式 = margin-removed50px ; border:1px solid#999999; width:400px; float:left; > < tr > < td 样式 = text-align:right; color:#21B7E5; > الصانع< / td > < td > 道奇< / td > < / tr > < td style = text-align:right; color:#21B7E5; > بلدالتجميع< / td > < td > 美国< / td > < / tr > < tr > < td style = text-align:right; color:#21B7E5; > عددالسجلات< / td > < td > 32 < / td > < / tr > < /表 > < / td > < / tr > < / table > < br / >

我希望提取每个属性的价值,如道奇,美国,32 任何人都可以帮助我... ... br /> 谢谢

解决方案

可能还有其他可能的选项来解决这个问题,但我能够实现这个使用jQuery的方式 -

( function (){ var str = ' < table>< tr>< td>< br> < div style =border:1px solid#999999; width:400px; float:left; margin-removed50px;> < p style =width:400px;> <峰; br> < img src =images / img1.gifstyle =float:right;> < / IMG>< / BR>< / P>< / DIV> < div class =clearstyle =height:5px;>< / div> < table class =normaltablestyle =margin-removed50px; border:1px solid#999999; width:400px; float:left;> < TR> < td style =text-align:right; color:#21B7E5;>الصانع< / td> < TD>道奇< / TD> < / TR> < td style =text-align:right; color:#21B7E5;>بلدالتجميع< / td> < td>美国< / td> < /表>< / BR>< / TD>< / TR> < TR> < td style =text-align:right; color:#21B7E5;>عددالسجلات< / td> < TD> 32< / TD> < / TR> < /表> < br />'; var arr = [];

(str).find(' td')。each( function (){ 如果(

hi all i have string at the run time contains html tags like this

<tr><td><br> <div style="border:1px solid #999999; width:400px; float:left;margin-removed50px;"> <p style="width:400px;"> <br> <img src="images/img1.gif" style="float: right;"> </div> <div class="clear" style="height:5px;"></div> <table class="normaltable" style="margin-removed50px; border:1px solid #999999;width:400px;float:left;"> <tr> <td style="text-align:right;color:#21B7E5;">الصانع</td> <td>Dodge</td> </tr> <td style="text-align:right;color:#21B7E5;">بلد التجميع</td> <td>United States</td> </tr> <tr> <td style="text-align:right;color:#21B7E5;">عدد السجلات</td> <td>32</td> </tr> </table> </td> </tr> </table> <br/>

and i want to extract the value of each attribute as Dodge, United States , 32 can any one helps me in this please... thanks

解决方案

There might be other possible options also to resolve this, but I was able to implement this way using jQuery -

(function() { var str = '<table><tr><td><br> <div style="border:1px solid #999999; width:400px; float:left;margin-removed50px;"> <p style="width:400px;"> <br> <img src="images/img1.gif" style="float: right;"> </img></br></p></div> <div class="clear" style="height:5px;"></div> <table class="normaltable" style="margin-removed50px; border:1px solid #999999;width:400px;float:left;"> <tr> <td style="text-align:right;color:#21B7E5;">الصانع</td> <td>Dodge</td> </tr> <td style="text-align:right;color:#21B7E5;">بلد التجميع</td> <td>United States</td> </table></br></td></tr> <tr> <td style="text-align:right;color:#21B7E5;">عدد السجلات</td> <td>32</td> </tr> </table> <br />'; var arr = [];

(str).find('td').each(function() { if(

更多推荐

在html文本中搜索字符串

本文发布于:2023-10-19 19:26:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1508531.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   html   文本中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!