JQuery selectors

I am trying to get an array of flags that are checked and have a specific attribute (tag) that is NOT empty.

(I know that the attribute is tagnot compatible with HTML, but it works through major browsers and makes life a lot easier!)

eg.

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

In the above example, there should be only the first code in the array that I started with:

$('input:checkbox:checked')

But this does not explicitly guarantee that the attribute is tagnot empty.

UPDATE
Sorry about what I had not thought about before - I also need to get a list of flags whose is tagempty so that the user can be warned. The following work does not work:

$('input:checkbox:checked[title=""]')
$('input:checkbox:checked:not([title])')

Thanks for all the answers, really appreciate!

UPDATE 2

( title ) - title! tag, .

+3
4
$("input:checkbox[tag!='']:checked")
+2

[tag = "first@whatever.com" ] JQuery; :

$('input:checkbox[tag="first@whatever.com"]:checked')

- JQuery, HTML, : http://docs.jquery.com/Data

+3

HTML

HTML:

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

:

$('input:checkbox:checked[alt!=""]')

http://jsfiddle.net/LVqLw/

+3

[tag], , .

: http://jsfiddle.net/xCFfa/

$(":checkbox:checked[tag]");
+2

Source: https://habr.com/ru/post/1764492/


All Articles