jquery child和children的区别

2025-04-04 01:22:41
推荐回答(1个)
回答1:

$("#contactlist").children()[1].children()[0].innerHTML=$(".contactname").val();
这里面
$("#contactlist").children()[1]
执行完的时候 返回的是一个dom对象
children()方法是jQuery对象的方法 不出错才怪。。
$($("#contactlist").children()[1]).children()[0].innerHTML=$(".contactname").val();
这样写就OK
PS:真心不懂您说的“什么时候用children”是什么意思。