JQuery selection button attribute element

My HTML:

<button class="btn btn-primary cl-width" ng-click="search()"> <i class="icon-search icon-white"></i>&nbsp;Search</button> <button class="btn cl-width" ng-click="criteriaModel.reset()"> <i class="icon> iconfa-undo"></i>&nbsp;Reset</button> 

My jQuery:

 $("button[ng-click:'search()]") 

Error displayed:

Error: syntax error, unrecognized expression: button [Ng-click: 'search ()]

Does jQuery support an attribute selector for a button element? I can achieve this $("button.btn-primary") , but I don't think this is good enough.

How can I select a button element by its attribute?

+4
source share
3 answers

Try

 $("button[ng-click='search()']") 
+10
source

try it

 $("button[ng-click='search()']").text() 

Demo

+3
source

use the following

 $("button[ng-click='search()']") 
+1
source

Source: https://habr.com/ru/post/1501617/


All Articles