3
I want to select all custom attributes and do a validation with them, but I don’t know how I can get the "attr" value inside a loop, since they are the ones being iterated.
HTML example:
<input type="text" data-selected="teste" value="fulano" name="nome">
<input type="text" data-selected="teste2" value="de tal" name="sobrenome">
Example:
$('[data-selected]').each(function(){
alert( $(this).attr() ); // -> teste / teste2
});
An explanation of the answer would be most welcome! ;)
– user28595
Thanks for the reply, but it is not limited only to input, can be select etc too
– Thiago
Logical. Just enter the target element in the jQuery! @Articunol selector!
– LipESprY
Why not just $(['data-Selected'])?
– Thiago
It works too. But when you set the selector on us
input
prevents seeking other "possible elements" that may not be desired...– LipESprY