I have this
$("input:radio").change(function() {
can i do something like
$(".someclass input:radio").change(function() {
Is that eve开发者_运维百科n correct and if not is there a better way
That'll match a radio input contained in an element with the class "someclass". Yes, it's valid, but without seeing your HTML I don't know if it's "correct".
You can give your radio button an ID and reference it with #id
if you think that's "better".
the class goes in place of the element type for most uses, it sounds like you want:
$(".someclass:radio")
note: $(":radio")
works fine by it self
It sounds like what you're trying to do is select all radio buttons that have a certain class, which can be accomplished like this:
$("input:radio.someclass").change(function() {
I don't use jQuery (I prefer plain old JavaScript), but you could use getElementsByClassName('someclass') then check them to make sure they're an input of type radio.
精彩评论