javascript - How to find all tags with a specific data- attribute? -
i need find tags have 'error' data bound them using jquery. have done. it's not working because added data attribute code.
$('form input').data('error',1); console.log( $('form input[data-error]') ); // empty
how can retrieve of them?
use filter()
$('form input').filter(function(){ return $(this).data('error'); // adjust if boolean not sufficient }).dosomething();
Comments
Post a Comment