开发者

How to select next element?

I'm working on tags list. There are maximum of five input tags. Firs开发者_Go百科t 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();

});


Have a look at jQuery.next().

$('.group_interests:eq(1)').change(function() {
    $(this).next().show();
});


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.

});


Use $(this).next().show(); This will work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜