ホバー状態で動的に作成された要素に問題があります。新しく作成されたhtml要素にカーソルを置くと、機能しません。まだここhttp://api.jquery.com/on/示すようjQuery 1.7 .on()ホバーを作成するには?
$('.hover').on({
mouseenter : function() {
alert('you hovered the button!');
},
mouseleave : function() {
alert('you removed the hover from button!');
}
});
、ない運:私もこのコードを試してみました
var createBtn = $("#create");
createBtn.click(function() {
$('div').append('<button class="hover">new hover button</button');
return false;
});
$('.hover').hover(function() {
alert('you hovered the button!');
}, function() {
alert('you removed the hover from button!');
});
:
<button id="create">create new button</button>
<button class="hover">hover me</button>
<div></div>
のjQuery:
は、ここに私のHTMLコードです。 デモ:http://jsfiddle.net/BQ2FA/
多分これはオン/オフについて助けになるでしょう:http://stackoverflow.com/questions/11283341/jquery-disable-click-until-animation-is-fully-complete –