name = "this or that" in jQuery? -


i have code:

$("input[name=foo]:checked,input[name=bar]:checked") 

but make smaller like:

$("input[name=foo|bar]:checked") 

is there that?

the shortest version, inputs things "should" have names.

$('[name=foo],[name=bar]'); 

a bit more safe inputs things can checked.

$(":checked").filter('[name=foo],[name=bar]'); 

exactly safe original selector, 2 characters shorter:

$("input:checked").filter('[name=foo],[name=bar]'); 

but agree, there no real need , you're better off spending time elsewhere.


Comments