tags:

views:

61

answers:

2

Is this JQuery valid? $("[name=enableTooltip]:checked")

What does it does?

+5  A: 

This is more understandable:

$("input[name=enableTooltip]:checked")

This selects all inputs which has name attribute equals "enableTooltip" and checked status is true.

Example match:

<input type="checkbox" name="enableTooltip" checked="checked" />
eyazici
+2  A: 

The selector [attr=val] is a shortcut for *[attr=val]. So [name=enableTooltip]:checked will select any element that’s name attribute value is “enableTooltip” and is checked (:checked this implies that the element is an INPUT element of the type checkbox).

Gumbo