Reputation: 21333
I'm working on tags list. There are maximum of five input tags. First two are shown by default... done! When user types something in some tag, it makes next tag visible. Not done.
This is what I have:
$('.group_interests:gt(1)').hide();
$('.group_interests:eq(1)').change( function() {
$(this) // How to show next element like :eq(+1) or something.
});
I don't know how to select this:eq(+1)
. Then I would simply .show()
and all would work!
Outcome:
$('.group_interests:gt(1)').hide();
$('.group_interests:visible').last().change( function() {
$(this).next().show();
});
Upvotes: 0
Views: 196
Reputation: 60574
Have a look at jQuery.next()
.
$('.group_interests:eq(1)').change(function() {
$(this).next().show();
});
Upvotes: 2
Reputation: 6999
use next() method to get next element in dom
$('.group_interests:gt(1)').hide();
$('.group_interests:eq(1)').change( function() {
$(this).next().show() // How to show next element like :eq(+1) or something.
});
Upvotes: 0