In trying to select elements that have any attributes, the following throws a jQuery syntax error.
$("div[*]")
Is there a selector to check if a tag has any attributes?
Tested with jQuery 1.3
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I went with Ariel Popovsky’s suggestion to use filter, though if I needed this in many places, I would use petersendidit’s suggestion of creating a customer selector.
The (important) difference is that the .specified property needs to be checked. IE always returns more than 80 attributes.
Note: even this is not 100%. There are some attributes, like INPUT .value, that are special cases, but since I’m using a DIV, I can ignore them.