所以我得到一堆动态生成的表,不可能从原点更改,我的问题是:使用JavaScript或任何客户端语言,我可以使用宽度= 154的表格进行筛选,我正在寻找为?
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="154" class="themesdivider">
<img src="/static/images/all/spacer.gif" alt="" width="154" height="1" border="0">
</td>
<td width="9">
<img src="/static/images/all/spacer.gif" alt="" width="9" height="1" border="0">
</td>
<td width="154" class="themesdivider">
<img src="/static/images/all/spacer.gif" alt="" width="154" height="1" border="0">
</td>
<td width="9">
<img src="/static/images/all/spacer.gif" alt="" width="9" height="1" border="0">
</td>
<td width="154" class="themesdivider">
<img src="/static/images/all/spacer.gif" alt="" width="154" height="1" border="0">
</td>
</tr>
<tr>
<td colspan="5">
<img src="/static/images/all/spacer.gif" alt="" width="10" height="2" border="0">
</td>
</tr>
<tr>
<td width="154" valign="top" align="left"><a href="/nf/Book/BookDisplay/0,,9780241957110,00.html" target='_top'>
<img src='/static/covers/all/0/1/9780241957110L.jpg' alt='This Is A Book' width=105 border=0></a>
<br>
<img src='/static/images/all/spacer.gif' alt='' width=1 height=8>
<br> <a href='/nf/Book/BookDisplay/0,,9780241957110,00.html' target='_top' class=themebooktitle><font color=>This Is A Book</font></a>
<br>
<img src='/static/images/all/spacer.gif' alt='' width='1' height='5' border='0'>
<br> <a href='/nf/Author/AuthorPage/0,,0_1000081296,00.html?sym=BIO' target='_top' class=themeauthor><font color=>Demetri Martin</font></a>
<br>
<img src='/static/images/all/spacer.gif' alt='' width='1' height='5' border='0'>
<br> <a href="/nf/Book/BookDisplay/0,,9780241957110,00.html" target='_top' class='thememore' onmouseover='javascript:document.images.a9780241957110.src="/static/images/all/more_arrow1.gif";' onmouseout='javascript:document.images.a9780241957110.src="/static/images/all/more_arrow.gif";'><img src='/static/images/all/more_arrow.gif' alt='' width=18 height=8 border=0 name='a9780241957110'><font color=>Read more...</font></a>
<br>
<img src='/static/images/all/spacer.gif' alt='' width='1' height='5' border='0'>
<br> <span class='themebookprice'><font color=>£9.99</font></span>
<br>
<img src='/static/images/all/spacer.gif' alt='' width='1' height='5' border='0'>
<br> <a href="/nf/Ecommerce/ShoppingCartChange?item=9780241957110" class=themeaddbasket><img src='/static/images/uk/addto_basket.gif' alt=''><img src='/static/images/all/spacer.gif' alt='' width='5' height='1'><font color=>Buy now</font></a>
<br>
<img src='/static/images/all/spacer.gif' alt='' width='1' height='5' border='0'>
<br>
<br>
</td>
<td width="9">
<img src="/static/images/all/spacer.gif" alt="" width="9" height="1" border="0">
</td>
<td width="154" valign="top" align="left"><a href="/nf/Book/BookDisplay/0,,9780241951774,00.html" target='_top'>
<img src='/static/covers/all/4/7/9780241951774L.jpg' alt='A History of the World in 100 Objects' width=105 border=0></a>
<br>
<img src='/static/images/all/spacer.gif' alt='' width=1 height=8>
<br> <a href='/nf/Book/BookDisplay/0,,9780241951774,00.html' target='_top' class=themebooktitle><font color=>A History of the World in 100 Objects</font></a>
<br>
<img src='/static/images/all/spacer.gif' alt='' width='1' height='5' border='0'>
<br> <a href='/nf/Author/AuthorPage/0,,0_1000079074,00.html?sym=BIO' target='_top' class=themeauthor><font color=>Neil MacGregor</font></a>
<br>
<img src='/static/images/all/spacer.gif' alt='' width='1' height='5' border='0'>
<br> <a href="/nf/Book/BookDisplay/0,,9780241951774,00.html" target='_top' class='thememore' onmouseover='javascript:document.images.a9780241951774.src="/static/images/all/more_arrow1.gif";' onmouseout='javascript:document.images.a9780241951774.src="/static/images/all/more_arrow.gif";'><img src='/static/images/all/more_arrow.gif' alt='' width=18 height=8 border=0 name='a9780241951774'><font color=>Read more...</font></a>
<br>
<img src='/static/images/all/spacer.gif' alt='' width='1' height='5' border='0'>
<br> <span class='themebookprice'><font color=>£9.99</font></span>
<br>
<img src='/static/images/all/spacer.gif' alt='' width='1' height='5' border='0'>
<br> <a href="/nf/Ecommerce/ShoppingCartChange?item=9780241951774" class=themeaddbasket><img src='/static/images/uk/addto_basket.gif' alt=''><img src='/static/images/all/spacer.gif' alt='' width='5' height='1'><font color=>Buy now</font></a>
<br>
<img src='/static/images/all/spacer.gif' alt='' width='1' height='5' border='0'>
<br>
<br>
</td>
<td width="9">
<img src="/static/images/all/spacer.gif" alt="" width="9" height="1" border="0">
</td>
<td width="154" valign="top" align="left"><a href="/nf/Book/BookDisplay/0,,9780141033570,00.html" target='_top'>
<img src='/static/covers/uk/9780141033570L.jpg' alt='Thinking, Fast and Slow' width=105 border=0></a>
<br>
<img src='/static/images/all/spacer.gif' alt='' width=1 height=8>
<br> <a href='/nf/Book/BookDisplay/0,,9780141033570,00.html' target='_top' class=themebooktitle><font color=>Thinking, Fast and Slow</font></a>
<br>
<img src='/static/images/all/spacer.gif' alt='' width='1' height='5' border='0'>
<br> <a href='/nf/Author/AuthorPage/0,,0_1000081748,00.html?sym=BIO' target='_top' class=themeauthor><font color=>Daniel Kahneman</font></a>
<br>
<img src='/static/images/all/spacer.gif' alt='' width='1' height='5' border='0'>
<br> <a href="/nf/Book/BookDisplay/0,,9780141033570,00.html" target='_top' class='thememore' onmouseover='javascript:document.images.a9780141033570.src="/static/images/all/more_arrow1.gif";' onmouseout='javascript:document.images.a9780141033570.src="/static/images/all/more_arrow.gif";'><img src='/static/images/all/more_arrow.gif' alt='' width=18 height=8 border=0 name='a9780141033570'><font color=>Read more...</font></a>
<br>
<img src='/static/images/all/spacer.gif' alt='' width='1' height='5' border='0'>
<br> <span class='themebookprice'><font color=>£8.99</font></span>
<br>
<img src='/static/images/all/spacer.gif' alt='' width='1' height='5' border='0'>
<br> <a href="/nf/Ecommerce/ShoppingCartChange?item=9780141033570" class=themeaddbasket><img src='/static/images/uk/addto_basket.gif' alt=''><img src='/static/images/all/spacer.gif' alt='' width='5' height='1'><font color=>Buy now</font></a>
<br>
<img src='/static/images/all/spacer.gif' alt='' width='1' height='5' border='0'>
<br>
<br>
</td>
</tr>
</table>
答案 0 :(得分:2)
您可以使用filter
:
var $tds = $('table td').filter(function() {
return $(this).width() == 154;
});
或者您可以直接检查属性值:
var $tds = $('table td').filter(function() {
return $(this).attr('width') == '154';
});
甚至只有一个选择器:
$('table td[width="154"]');
我认为后两个选项会更可靠,因为不同浏览器的边距/填充不同。