を設定した後、イベントを添付する最初のこれは私がページネーションを行うための機能で使用し、私のjQueryのコードのexempleです:jQueryの:すぐにHTMLコンテンツ
// new_content is a variable that holds the html I want to add to a div
$('div#my_div').html(new_content);
$("div#my_div a.details").hover(function(){
$(this).fadeIn(); //code to execute when the mouse get in
}, function(){
$(this).fadeOut(); //code to execute when the mouse get out
});
しかしホバーイベントがまったく動作しません私はDOMがまだ準備ができていないので、これが原因であると信じています!
及びこれを回避するために私はこのようなタイマー設定を使用:私は、これはHTMLメソッドの後すぐにイベントをアタッチする正しい方法ではないことを確信しているので、私はこの質問をした
$('div#my_div').html(new_content);
window.setTimeout(
$("div#my_div a.details").hover(function(){
$(this).fadeIn(); //code to execute when the mouse get in
}, function(){
$(this).fadeOut(); //code to execute when the mouse get out
});
,100);
を(多分それは仕事ではなかった!)。
私は誰かが私にそれを行う正しい方法を示すことを願っています。
最初にありがとう、私はあなたの例を試してみました。 – Hidalgo
あなたのコードはelseブロックの命令だけを実行するので、mouseoverでmouseenterを変更しましたが、今は完全に動作します。 – Hidalgo