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

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -