마우스를 올리면 동적으로 생성 된 요소에 문제가 있습니다. 새로 만든 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-isfully-complete –