情報を動的に取り込むループがあります。私は「AJAX」を呼び出しています特定のdivをクリックする上jQueryで現在の要素をクラス内部で選択する方法は?
<div class="main">
<div class="more">
more
</div>
<span></span>
....
<div class="more">
more
</div>
<span></span>
</div>
- 成功には、私はいくつかの内容と、その特定のdivの内容と次のスパンを上書きしたいです。
$(document).on("click", ".more", function (event) {
$.ajax({
url: '..',
datatype: 'application/json',
success: function (data) {
$(".more",this).html("Update Dev"); //update div
$(".more",this).find('span:first').text("Update Span"); //update span
},
error: function() { alert('something bad happened'); }
});
});
クリックされた要素にはどのようにアクセスしますか。
おかげ
$(これは必要なものです) –
使用event.target – user3599803
複製のhttp://stackoverflow.com/questions/2643798/how-to-access-the-this-inside-ajax-success-callback-function –