Sto riscontrando un problema con gli elementi creati dinamicamente sullo stato di hover. Quando passo il mouse sull'elemento html appena creato, non funziona.Come rendere jQuery 1.7 .on() hover?
Ecco il mio codice HTML:
<button id="create">create new button</button>
<button class="hover">hover me</button>
<div></div>
jQuery:
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!');
});
Ho anche provato questo codice:
$('.hover').on({
mouseenter : function() {
alert('you hovered the button!');
},
mouseleave : function() {
alert('you removed the hover from button!');
}
});
come mostrato qui http://api.jquery.com/on/, ma ancora senza fortuna. Ecco anche la demo: http://jsfiddle.net/BQ2FA/
forse questo aiuterà su on/off: http://stackoverflow.com/questions/11283341/jquery-disable-click-until-animation-is-fully-completo –