var foot = document.createElement("div");
开发者_如何学JAVA $('<div class="t"></div><div class="b"></div>').appendTo(foot);
foot.id='foot';
//*****
$(foot,'> .t').mouseover(function(){...})
i want to get the '.t' div element,
but now ,the 'foot' div is not already appenTo the 'document.body' ,
so i can't use this $('#foot .t'),
and i use this:$(foot,'> .t'), but ,i get the $(foot),
so how do i get the foot's '.t' element using jquery
thanks
Just switch the two parameters that you pass to $
:
var foot = document.createElement("div");
$('<div class="t">tt</div><div class="b">bb</div>').appendTo(foot);
foot.id='foot';
alert($('.t', foot).html());
// Output: "tt"
精彩评论