在jQuery中双击功能不起作用 [英] Double click function in jQuery is not working
本文介绍了在jQuery中双击功能不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在页面中有两个span元素。当我在两者上调用jquery双击函数时,该函数仅在第一个元素上调用。我使用以下代码:
I have two span elements in a page. when I call a jquery double click function on both then the function is called only on first element. I am using the following code:
<span id="shiftTime_1">1</span>
<span id="shiftTime_2">1</span>
和jquery函数是:
and jquery function is:
$("[id^='shiftTime_']").dblclick(function() {
alert("hello");
});
。那么功能正常。但是,当我双击shiftTime_2的元素Id时,此函数不响应。
when I double click on the element Id of shiftTime_1. then the function works fine. But when I double click on element Id of shiftTime_2 then this function does not respond.
请帮忙。
谢谢
Please help. Thanks
推荐答案
尝试在 $内使用$(文件).ready()
$(document).ready(function(){
$("[id^='shiftTime_']").dblclick(function() {
alert("hello");
});
});
这篇关于在jQuery中双击功能不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文