1
$('[role="button"]').click(function () {
            myMethod();
        });

私はそれが呼び出す何かをクリックすると知っていますが、myMethod()何をクリックしますか?

とはroleどういう意味ですか?

これはボタンですか?

<input type="button" ... />

とは: [role="button"]?

4

4 に答える 4

8

アトリビュート イコールセレクターです。$('[role="button"]')属性が にrole設定されているすべての要素を選択しますbutton

例:
実行すると、以下の 3 つがすべて選択されます。$('[role="button"]')

<div role="button" ></div>
<p role="button" ></p>
<button role="button"></button>

しかし、これはしません

<input type="button">
于 2012-10-17T16:31:02.517 に答える
3

値がボタンである属性ロールを持つセレクター

$('[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
于 2012-10-17T16:31:29.137 に答える
1

セレクターは、 にrole等しい属性を選択していますbutton

于 2012-10-17T16:30:52.953 に答える
1

それは属性が等しいセレクターです

于 2012-10-17T16:31:37.400 に答える