views:

43

answers:

1

what does this jquery selector means $("*[regex]")

I want to select all controls which have an attribute regex.

+4  A: 

It's selecting all elements with a regex= attribute (that it's present, it can be empty).

Though, the all selector can be implied, it can just be:

$("[regex]")

Both are very inefficient though it would be better to add the element type or anything to narrow it down before looking for attributes.

Nick Craver
If I want to have a selector which have regex= and error= both attributes together
vaibhav
@vaibhav - Add them beside each other without a space to only select elements that have both: `$("[regex][error]")`.
Nick Craver
@vaibhav: you can chain strings together like `$('[regexp][error]')`
jAndy
@Nick: seriously, do you have a script or something that autorefreshes stackoverflow all the time? :p
jAndy
@jAndy - the notification icon in the toolbar (The stackexchange one) is instant how, so I see replies quicker than before it was added, yes :)
Nick Craver