开发者

how to get $(foot,'> .t') in my code, i using jquery

开发者 https://www.devze.com 2022-12-23 08:12 出处:网络
var foot = document.createElement(\"div\"); 开发者_如何学JAVA$(\'<div class=\"t\"></div><div class=\"b\"></div>\').appendTo(foot);
        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"
0

精彩评论

暂无评论...
验证码 换一张
取 消