Take the 2-minute tour ×

I am trying to get an array of checkboxes that ARE checked AND have a certain attribute (tag) that is NOT blank.

(I know that the attribute called tag is not HTML compliant but it does work across the major browsers and makes life alot simpler!)


<input type="checkbox" name="First" tag="first@whatever.com" checked="checked">
<input type="checkbox" name="Second" tag="" checked="checked">

In the above example, only the first one should be in the array The code I have started with is:


But that obviously doesnt ensure that the tag attribute is not blank

Sorry, something I didnt think of before - I also need to get a list of the checkboxes whose tag is blank so the user can be warned. The following dont work:


Thanks for all the responses, much appreciated!


The above code (using title to store the additional data) doesnt work purely it seems because of the title atribute! When I changed it to tag it worked perfectly.

share|improve this question
Why not use alt, which is HTML compliant? –  Robert Sep 13 '10 at 12:43
@Robert: because alt has a defined function in the browser. Alt is about the appearance. –  Georg Schölly Sep 13 '10 at 12:48
Consider using data-tag instead of tag, ala: dev.w3.org/html5/spec/… –  Dave Ward Sep 13 '10 at 12:49
@Georg alt is meant as a short description for user agents that can't display forms/images etc. –  Robert Sep 13 '10 at 12:51
add comment

4 Answers

up vote 2 down vote accepted
share|improve this answer
add comment

attributes use the [tag="first@whatever.com"] syntax in JQuery; try appending that as in:


The other option is you may want to check out the data method in JQuery, which can append data to an HTML element, instead of using the tag attribute: http://docs.jquery.com/Data

share|improve this answer
add comment

HTML compliant


<input type='checkbox' alt='bleh' checked='checked' id='1' />
<input type='checkbox' alt='' checked='checked' id='2' />

And Selector:



share|improve this answer
add comment

You can simply use [tag] to test if it is blank or if the tag exists at all.

Example: http://jsfiddle.net/xCFfa/

share|improve this answer
add comment

Your Answer


