- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
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?
like this:
$(‘input[name=a]’).on(‘change’,function(e){
//how to get the $(‘input[name=a]’) again.
//cause it maybe uncertain;
});
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?
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.
yes, $(this) can get element which onchange, but just one.
I mean get the $(‘input[name=a]‘) jquery collect again.
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
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]
.