在javascript中创建元素,然后使用jquery动画
我已经通过javascript创建了一个noty,在其中我使用了以下几个元素:在javascript中创建元素,然后使用jquery动画,javascript,jquery,html,Javascript,Jquery,Html,我已经通过javascript创建了一个noty,在其中我使用了以下几个元素: var n = noty({ layout: 'centerRight', theme: "defaultTheme", text: "<img class='item' src='images/emark.png' width='30' heig
var n = noty({
layout: 'centerRight',
theme: "defaultTheme",
text: "<img class='item' src='images/emark.png' width='30' height='30'/>" + count,
type: 'alert',
template: "<a id='noty' title='Click Here to see all recent alerts' href='alertjquery.html' target='_blank'><div id ='noty_message'><span class='noty_text'></span></div></a>",
closeWith: ['button'],
dismissQueue: true,
timeout: false
});
我想做的是,当你将鼠标悬停在标有id的noty上时,里面的图像会稍微放大。我认为我使用noty并不重要,它应该可以正常工作,不管怎样您缺少
到id
的目标元素:
$('#noty')
此外,由于元素是动态创建的,因此需要使用:
$('body').on("hover","#noty",function(){
//some operation
});
另一个注意事项是,hover()
使用两个处理程序,当您将鼠标悬停在元素上并将其移出时,会触发该处理程序。因此,您可能还需要在鼠标移出元素时处理该情况。您应该使用
它帮助您为将来的元素附加处理程序
$('body').on("hover","#noty",function(){
//some operation
});
$(document).on("hover","#noty",function(){
width = $('.item').width() * zoom;
height = $('.item').height() * zoom;
$(this).find('.item').stop(false, true).animate({ 'width': width, 'height': height, 'top': move, 'left': move }, { duration: 300 });
});