admin管理员组文章数量:1393081
does anybody know an solution for buttons to react on 2 click events for only one button:
<input type="button" value="Click" ondblclick="alert('double')"; onclick="alert('ones')";>
@At my try if I double click on button, it alert only 'ones'; Why it isn't possible to have ondblclick and onclick in the same button?
does anybody know an solution for buttons to react on 2 click events for only one button:
<input type="button" value="Click" ondblclick="alert('double')"; onclick="alert('ones')";>
@At my try if I double click on button, it alert only 'ones'; Why it isn't possible to have ondblclick and onclick in the same button?
Share Improve this question edited Jun 30, 2015 at 15:06 Яраслаў Жук 537 bronze badges asked Sep 11, 2013 at 10:39 ButtersButters 1,0575 gold badges15 silver badges25 bronze badges 5- Is it something like you want to restrict the user from double-clicking? – Ganesh Pandhere Commented Sep 11, 2013 at 10:41
- Then don't use alert which is modal and fired a blur event in most browsers – A. Wolff Commented Sep 11, 2013 at 10:41
- why do you want such behavior doesnt look good to me – Prabhu Murthy Commented Sep 11, 2013 at 10:42
- If you double click the button then alert('ones') will appear on your screen.What do you wants to do ? – Satyam Koyani Commented Sep 11, 2013 at 10:45
- It is possible, but why would you want a double-click handler on a button element? It could make sense on a number of other elements (e.g., an option element within a (non drop-down) select element where one click selects and the second submits or something), but I've never needed to handle a double-click on a button. – nnnnnn Commented Sep 11, 2013 at 10:51
2 Answers
Reset to default 6<input type="button" value="Click" ondblclick="console.log('double');" onclick="console.log('ones')";>
Magically, it works!
Your problem is you are using alert()
which is modal and so makes your ondblclick event impossible to be fired.
You an give timeout for click so that alert pops up bit slow..
<input type="button" value="Click" ondblclick="alert('double')"; onclick="setTimeout(function(){alert('ones')},3000);";>
本文标签: jqueryJavascript onclick and ondblclick in same buttonStack Overflow
版权声明:本文标题:jquery - Javascript onclick and ondblclick in same button - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744599735a2614995.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论