Pat*_*eon 23 javascript jquery
我试过这个.我认为$("div.tab_select")[0]的返回Object 不是jQuery对象,但我甚至不能使用纯javascript方法.
有没有办法让它成为jQuery Object?例如$($("div.tab_select")[0]) ..我知道这很傻;
谢谢你的阅读.
var tmp = $("div.tab_select")[0];
alert(tmp); //This gives me HTMLDivElement collectly. But I can't use any of javascript..
alert(tmp.nodeName); //But this give me error "Uncaught TypeError: Cannot read property 'nodeName' of undefined"
tmp.hide(); //Neither, I can't use this.
Run Code Online (Sandbox Code Playgroud)
jma*_*777 34
// all divs with tab_select class
$('div.tab_select')
// first div with tab_select class
$('div.tab_select:first')
// or CSS pseudo selector which is slightly faster than the first jQuery
// shortcut
$('div.tab_select:first-of-type')
// or
$('div.tab_select').first()
// or
$('div.tab_select:eq(0)')
// or
$('div.tab_select').eq(0)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
36560 次 |
最近记录: |