Reputation: 10713
$('[role="button"]').click(function () {
myMethod();
});
I know that on click on something it calls myMethod()
, but on click on what?
What does role
mean?
Is this button?
<input type="button" ... />
What is: [role="button"]
?
Upvotes: 0
Views: 83
Reputation: 79830
It is an attribute equals selector. $('[role="button"]')
would select all elements that has attribute role
set to button
.
For ex:
All below three will be selected when you do $('[role="button"]')
<div role="button" ></div>
<p role="button" ></p>
<button role="button"></button>
But this will not
<input type="button">
Upvotes: 8
Reputation: 55740
Selector with attribute role whose value is button
$('[role="button"]') ; // It is not the button in context
//
<input role="button" ... /> // this is selected
<input type="button" ... /> // Not this
<input role="button" ... /> // this is selected
Upvotes: 3
Reputation: 190925
The selector is selecting on the role
attribute that is equal to button
.
Upvotes: 1