如何使用jquery提取子文本数据?(how extract child's text data using jquery?)
我想从下面给出的html中提取数据'AT401726'
<td class="publicationInfoColumn"> <h4>Publication info:</h4> AT401726<br>2008-08-15 </td>&我使用JQuery解决了它,下面给出了工作代码
('body').find('.publicationInfoColumn').clone().children().remove().end().text()是否还有其他更好的技术从上面给出的HTML提取数据? 在我的抓取的html页面中有很多像上面这样的html
i want to extract data 'AT401726' from the html given below
<td class="publicationInfoColumn"> <h4>Publication info:</h4> AT401726<br>2008-08-15 </td>& i solved it by using JQuery, the working code is given below
('body').find('.publicationInfoColumn').clone().children().remove().end().text()is there any other better technique to extract data from above given html ? there are many html like above in my crawled html page
最满意答案
您正在寻找h4元素的下一个兄弟元素的内容,请尝试
var text = $.trim($('.publicationInfoColumn h4').prop('nextSibling').nodeValue); console.log(text)演示: 小提琴
The text you are looking for the the contents of the next sibling element of the h4 element, so try
var text = $.trim($('.publicationInfoColumn h4').prop('nextSibling').nodeValue); console.log(text)Demo: Fiddle
更多推荐
html,given,电脑培训,计算机培训,IT培训"/> <meta name="description"
发布评论