Best way to find “next” form input element in jQuery?

前端 未结 12 1618
滥情空心
滥情空心 2020-12-02 18:18

Using jQuery, what\'s the best way to find the next form element on the page, starting from an arbitrary element? When I say form element I mean ,

12条回答
  •  心在旅途
    2020-12-02 18:52

    redsquare is absolutely right, and a great solution also, which I also used in one of my project.

    I just wanted to point out that he is missing some parentheses, since the current solution concatenates the index with 1, instead of adding them together.

    So the corrected solution would look like:

    $(":input:eq(" + ($(":input").index(this) + 1) + ")");
    

    Sorry about the double-post, but I couldn't find a way to comment his post...

提交回复
热议问题