$('[role="button"]').click(function () {
myMethod();
});
私はそれが呼び出す何かをクリックすると知っていますが、myMethod()何をクリックしますか?
とはroleどういう意味ですか?
これはボタンですか?
<input type="button" ... />
とは: [role="button"]?
$('[role="button"]').click(function () {
myMethod();
});
私はそれが呼び出す何かをクリックすると知っていますが、myMethod()何をクリックしますか?
とはroleどういう意味ですか?
これはボタンですか?
<input type="button" ... />
とは: [role="button"]?
アトリビュート イコールセレクターです。$('[role="button"]')属性が にrole設定されているすべての要素を選択しますbutton。
例:
実行すると、以下の 3 つがすべて選択されます。$('[role="button"]')
<div role="button" ></div>
<p role="button" ></p>
<button role="button"></button>
しかし、これはしません
<input type="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
セレクターは、 にrole等しい属性を選択していますbutton。
それは属性が等しいセレクターです