Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript how to get the elements in event?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #171122
    singlexyz
    Participant

    like this:
    $(‘input[name=a]’).on(‘change’,function(e){
    //how to get the $(‘input[name=a]’) again.
    //cause it maybe uncertain;
    });

    http://jsbin.com/juditeyu/1/edit

    #171124
    Paulie_D
    Member

    Are you trying to get the value?

    Checkboxes wouldn’t all have the same [name]….or would they?

    I’m actually unsure on that one….I’m sure I’ve seen it done but I don’t know if it’s valid.

    Are you after and radio button group?

    #171127
    Paulie_D
    Member

    Aha….I think I’ve found something. You can use the same [name] but each checkbox should have a unique attribute to identify it. An #ID would work.

    http://www.w3.org/TR/WCAG20-TECHS/H71.html

    #171381
    singlexyz
    Participant

    yes, $(this) can get element which onchange, but just one.

    I mean get the $(‘input[name=a]‘) jquery collect again.

    #171382
    singlexyz
    Participant

    Aha…I think the code is easy to confused.

    here’s what I want:
    var checkbox = $(‘input[name=a]‘);
    checkbox.on(‘change’,function(e){
    // I want to get the checkbox again.
    // but can I get that without var checkbox = ….?
    // $(this) means the elements which onchange, not the collect.
    });

    XD

    #171424
    Paulie_D
    Member

    I mean get the $(‘input[name=a]‘) jquery collect again.

    OK…but what are you going to do with it…I’m trying to understand why you need to re-select it/them….especially as there will be more than one input[name=a].

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.