javascript - jquery array confusion -


i have web page bunch of tables decorated datatable jquery plugin. when page loaded, they're hidden. have function toggles them based on index:

function expand_job(i) {     $(".datatables_wrapper")[i].show(); } 

but didn't work. browser complains show() not function. work around, i'm doing this:

function expand_job(i) {     $(".datatables_wrapper").each( function(idx) {         if ( == idx ) {             $(this).slidetoggle(300);         }     }); } 

that works fine it's..... can't let go.

so why did first piece of code not work? because [i] takes jquery object , normal js object , result lost jquery functionality?

thanks,

use .eq():

$(".datatables_wrapper").eq(i).show(); 

jquery arrays contain underlying dom elements @ each index, when access them dom functions available not jquery methods.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -