当前位置: 动力学知识库 > 问答 > 编程问答 >

Need jquery selector

问题描述:

I have the following snippet of code on a page that I need to specifically target the number inside the b tag and put that number in a variable. I do not have direct access to this code or I would put and ID there. There are more than one td and b tags on the page but only one font size"3". What would be the correct selector to target this text?

<td><font size="3"><b>3947</b></font></td>

This is the code I have so far but it returns other bold text on the page

<script type="text/javascript" language="javascript">

$(document).ready(function(){

var invoice_number = $("td b").text();

alert(invoice_number);

});

</script>

网友答案:

Use an attribute equals selector, like this:

$(document).ready(function(){
  var invoice_number = $("td font[size='3'] b").text();
  alert(invoice_number);
});

You can give it a try here.

分享给朋友:
您可能感兴趣的文章:
随机阅读: