您好,以下是我的代码片段。我想做的是,我想在 image_div
中找到 img
并将 draggable
事件附加到它。
$(function() {
jQuery('#image_div').each({
$(this).find('img').draggable({revert: true});)};
});
上面的代码抛出以下错误
SyntaxError: missing : after property id//$(this).find('img').draggable({revert: true});
最佳答案
你太复杂了..
这是您更新的 fiddle .. http://jsfiddle.net/jFIT/FCjr5/1/
JQuery 中的选择器总是返回一个对象数组。您不需要使用循环遍历它们来为每个按钮创建事件。例如,具有相同类“buttonClass”的 5 个按钮具有相同的点击事件:$('.buttonClass').click (函数 () { ..... });
关于javascript - Jquery Draggable 抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22539323/