mercredi 1 juillet 2015

jQuery: How to add the attribute in $(this)?

Example I have 10 textbox and each has the same attribute with different value, say for example they have an attribute data-same with different value and I have something like this in my code
$('#test').each(function(){ $(this).val(); });
and I want to filter the result using the attribute of each textbox. How would I do it? I was thinking on doing something like this
$('#test').each(function(){ $('[data-same="val1"]',this).val(); });
but I'm not sure about it.

Aucun commentaire:

Enregistrer un commentaire