Lets assume I have the following html:
<ul class="list">
<li></li>
<li></li>
<li></li>
</ul>
I cannot do something like thi开发者_如何学编程s: (using .get() and refering by index value:
$(document).ready(function(){
$('li').get(0).html('some_text')
});
Thanks.
That's because get
returns the DOM element, not a jQuery selection. The html
method is a jQuery one, not a DOM one. You need eq
instead:
$(document).ready(function(){
$('li').eq(0).html('some_text')
});
精彩评论