jQuery可调整大小的.Live() [英] jQuery resizable .Live()
本文介绍了jQuery可调整大小的.Live()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试破坏可调整大小的div时,.ui-resizable-se上的悬停功能不起作用.我想我必须使用jquery live().但是我无法清楚地整合它.
When I try to destroy resizable div, hover function on .ui-resizable-se doesn't work. I think I have to use jquery live(). But I couldn't integrate it clearly.
如果在页面加载时将.ui-resizable-se或.ui-resizable-e悬停,则功能将起作用,但是如果再次悬停,则将不会发生任何事情.我该如何克服这个问题?
If you hover .ui-resizable-se or .ui-resizable-e when page load, functions will work, but if you hover again, nothing will be happened. How can I overcome this problem?
$('#resizable').resizable({
aspectRatio:false
});
$('.ui-resizable-se').hover(function(){
keep("resizable");
});
$('.ui-resizable-e').hover(function(){
dontKeep("resizable");
});
源链接: http://jsfiddle.net/nNrgP/
推荐答案
请尝试使用事件委托,因为您可能正在处理动态元素
Try using event delegation since you might be dealing with dynamic eleemnts
$(document).on('mouseenter mouseleave', '.ui-resizable-e', function(){
dontKeep("resizable");
});
$(document).on('mouseenter mouseleave', '.ui-resizable-se', function(){
keep("resizable");
});
演示:小提琴
这篇关于jQuery可调整大小的.Live()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文