SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist stonedeft's Avatar
    Join Date
    Aug 2009
    Posts
    586
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jquery select all elements after

    Hello forums

    I have these elements

    Code HTML4Strict:
     
    <select id="a"></select>
    <select id="b"></select>
    <select id="c"></select>
    <select id="d"></select>

    if I changed the value of B :

    Code Java:
    $(document).ready(function(){
     
      $('#b').change(function(){
        //target   c,d and set attr to disabled
     
       });
     
    })

    how do I target all the elements after b?
    Any ideas?
    Don't Panic

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    There are several different ways.

    You could use the Next Adjacent Selector (“prev + next”), or you could use the $.next() method, or you could use the $.siblings() method, depending on which way you feel like coding.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Evangelist stonedeft's Avatar
    Join Date
    Aug 2009
    Posts
    586
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks pmw57 I think the nextAll() function will work.
    Don't Panic

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by stonedeft View Post
    Thanks pmw57 I think the nextAll() function will work.
    Agreed, the $.nextAll() method is the most efficient way to go.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •