javascript - variable with lt jQuery -


here js looks

var h = 9; $('#list li:lt('+x')').show(); if (x < listnumber) {   $('#list li:lt(5)').hide(); } 

i think can cache $('#list li') var,

var $list = $('#list li') 

but how can combine it? tried following format, doesn't work me

$('#list li')+(':lt(5)') or $('#list li').is(':lt('+x+')')? 

once cache $('#list li') in var, use .filter() on variable.

for more information on how use .filter() api function http://api.jquery.com/filter/

var h = 9; var $cacheditems = $('#list li'); $cacheditems.filter(':lt(' + h + ')').show(); if (x < listnumber) {   $cacheditems.filter(':lt(5)').hide(); } 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -