jquery の $(this) と $('this') の違いは何ですか?
1128 次
3 に答える
7
于 2012-10-03T15:43:55.877 に答える
1
$(これ)
jQuery Object に囲まれた現在のコンテキストを次に示します。
$('this') -- これは単なる文字列です..
$('#btn').on('click', function() {
$(this).attr('id');
// Here $(this) is the current current button context that was clicked with i**d btn**
});
したがって、$(this) は常に問題の現在のコンテキスト オブジェクトを取得します。
デフォルトでは、これはコンテキスト内でネイティブ DOM 要素です...
于 2012-10-03T15:44:30.693 に答える
1
$('this') は使用されません... IDの $("#this") またはクラスの $(".this")のみが機能します
EDIT: または $('this') ただし、タグがある場合にのみ使用されます (後述)
于 2012-10-03T15:45:29.900 に答える