I have a list set with display:none
and some code to show item 3:
HTML:
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
</ul>
jquery:
var item = '1';
$("li:gt(1):lt(1)").show();
Is it possible to get the var inside the gt selection? Al I can think of is this
$("li:gt('+item+'):lt(1)").show();
Doesn't work. Can this be done? If not what else can I try?
Example: http://jsfiddle.net/BSakQ/5/
You need to delimit the string with the correct quotes. Try this:
$("li:gt(" + item + "):lt(1)").show();
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