[英]dom traversal using jquery
I have this html and want to traverse the dom and place a value in the span that has the 我有这个HTML,并希望遍历dom并在具有的跨度中放置一个值
class="center"
after the page is loaded using jquery. 使用jquery加载页面后。 I must take into consideration that the are other html on the same page with same structre as this.
我必须考虑到同一页面上的其他html与此结构相同。 The only difference is that each of them has a unique td id.
唯一的区别是每个人都有一个独特的td id。 Here is the html:
这是html:
<table>
<tr>
<td id="bankname">
<div unselectable="on" style="-webkit-user-select: none; -webkit-tap-highlight-color:
rgba(255, 255, 255, 0); width: 66px; " class=" select-area select-modify_select
select-focus ">
<span class="left"></span>
<span class="center">B.N.S.</span>
<a class="select-opener"></a>
</div>
</td>
<tr>
</table>
$(function(){
$('#bankname span.center').text( theValueYouWant );
});
This way you search for a <span>
tag having center
class inside #bankname
element. 这样,您可以在
#bankname
元素中搜索具有center
类的<span>
标记。
$('#bankname span.center').text( newValue );
$('#bankname span.center').text('Hello World!!');
我更喜欢.html() ,因为它比.text()快一点
$('#bankname span.center').html('Hello World!!');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.