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
Post a Comment