初始表格完整html是从其他网站提取的。Jquery获取此节点的原始html
我需要为它做进一步的处理。
当语句匹配时,我只想获取整个表格的html块,以覆盖当前<body>
标记内的内容。
现在的问题是无法打印出整个表格的html块。
'标题标题'是动态值。我会不时添加更多的比较标准。如果匹配,那么我将只检索表html,starting from <table> to </table>
,所有其他htmls在body标签内但在表标签之外需要消除。
<body>
<!-- Additional HTMl code -->
<div align="right">
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" valign="top"><strong>Header Title</strong></td>
</tr>
<tr>
<td height="32" valign="top">Date : <strong>01/01/2011 </strong> <br></td>
</tr>
<tr>
...
</tr>
</table>
<!-- Additional HTMl code -->
</div>
</body>
$("*").each(function() {
if($(this).children().length==0){
if($(this).text()=="Header Title"){
alert('match');
alert($(this).closest('table').html()); //not working...
}
}
恐怕你的问题还不清楚。你能解释一下你需要做什么,以及你现在正在做什么不工作? – 2011-02-04 16:31:42
基本上'标题标题'是动态值。 我会不时添加更多比较标准。 如果匹配,那么我只会检索表html(对于其他用法),其他所有htmls在body内都不需要。 – 2011-02-04 16:43:25