I tried this below. I think the return Object of $("div.tab_select")[0] isn't a jQuery Object, but I can't even use pure javascript method.
Is there any way to make it jQuery Object? for instance $($("div.tab_select")[0])..I know this's silly;
Thank you for reading.
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.
In one of them, we will use a method and in the other one, we will use not selector. Approach 1: First, select the DIV with certain class using jQuery Selector and then use :not selector to ignore the elements of specific class. Example: This example implements the above approach.
In jQuery, the class and ID selectors are the same as in CSS. If you want to select elements with a certain class, use a dot ( . ) and the class name. If you want to select elements with a certain ID, use the hash symbol ( # ) and the ID name.
// 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)
if you want a jQuery object use var tmp = $("div.tab_select:first")
instead.
var tmp = $("div.tab_select")[0]
will return the DOM element (if exists)
Just do $(tmp)
. [0] gives you the HTML-Element not the JQuery instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With