在jQuery事件处理程序中调用自定义函数
Calling a custom function in jQuery event handler
这是我想要调用的函数(我测试过它,它肯定有效):
function enableCategoryPopup(event) {
event.stopPropagation();
var buttonOffset = $(this).offset();
$('.category-popup').css({
top: buttonOffset.top + 10,
left: buttonOffset.left +10
});
$('.category-popup').show(100);
}
这就是我想称之为的地方
$(document).on("mousedown", ".tab-links li:nth-child(2)", function(event) {
if (event.which == 3) {
enableCategoryPopup();
}
});
当我右键单击指定的元素时,应该立即调用我的自定义函数,但它没有。当我调用alert("x")
而不是enableCategoryPopup()
时,它起作用,只有我的自定义函数不会被执行。
我做错了什么?如何调用我的自定义函数?
尝试从enableCategoryPopup函数中处理事件
function enableCategoryPopup(event) {
if (event.which == 3) {
event.stopPropagation();
var buttonOffset = $(this).offset();
$('.category-popup').css({
top: buttonOffset.top + 10,
left: buttonOffset.left +10
});
$('.category-popup').show(100);
}
}
$(document).on("mousedown", ".tab-links li:nth-child(2)", enableCategoryPopup);
相关文章:
- 具有自定义函数调用的 HTML 表单
- 使用 jQuery 对动态创建的元素调用自定义函数
- Angular2 在创建 ngSwitch 新视图后调用自定义函数
- 调用插件外部的自定义函数并传递参数
- jQuery:点击事件后调用自定义函数
- 调用自定义数据属性中的函数
- jQuery 在单击时调用自定义函数
- 可能调用的自定义函数列表
- 从firebug控制台调用自定义函数
- 在jQuery事件处理程序中调用自定义函数
- 我没有'我不想两次调用自定义函数
- 当第三方javascript异步函数完成执行时,调用自定义函数
- 是否有一种方法可以在调用对象的未定义函数时调用自定义函数?
- 如何在jqGrid中设置双击函数来调用自定义函数?
- 在java脚本中调用自定义函数而不是getfullyear()
- 从'外部'调用自定义函数中的函数
- 调用自定义函数时发生ReferenceError
- 在d3中调用自定义函数
- 是否可以使用setTimeout Node.js调用自定义函数
- 如何在jquery ajax成功调用之前调用自定义函数