私はAJAXを使用して記事を表示するワードプレスサイトに取り組んでいます。成功コールバックにjqueryコードを追加しました。私のニーズの1つは、マウスオーバーで画像を表示することです。マウスオーバー効果を除いて、私のコードはすべて機能します。
だからこれは私のajax関数です:
function loadArticle(pageNumber, loop, term){
$.ajax({
url: ajax_var.url,
type:'POST',
data: someData,
success: function(html){
// This will be the div where our content will be loaded
$("#content").append(html);
// Zoom box
$('img.static').hide();
$(".ad-preview").live({
mouseover: function() {
$(this).find('img.static').stop().fadeIn();
},
mouseout: function() {
$(this).find('img.static').stop().fadeOut();
}
});
// Other stuff...
});
return false;
}
});
およびHTML:
<div class="ad-preview">
<a target="_blank" href="">
<img src="img/zoom.png" /></a>
</a>
</div>
この効果を実装するための良い方法は何ですか?