[英]Can a link have both an onclick jquery and javascript event?
I have a link that jQuery listens to, and if clicked it will toggle another div. 我有一个jQuery侦听的链接,如果单击它,将切换另一个div。 The link also has an onclick javascript action.
链接中还有一个onclick javascript操作。 When I click the link, the div I want to toggle shows, but the javascript doesn't execute.
当我单击链接时,要切换的div会显示,但是javascript无法执行。
jQuery script jQuery脚本
$(function() {
$('#links a').live('click', function() {
$("#showall").toggle('slow');
});
});
my link 我的链接
<div id ="links">
<a href="some javascript" onclick="javascript">Play</a>
</div>
for me the following is working in Chrome, Firefox and IE. 对我来说,以下内容适用于Chrome,Firefox和IE。 Both pure Javascript (onclick) and jQuery click() get executed.
纯Javascript(onclick)和jQuery click()均会执行。
<html>
<head>
<script type="text/javascript" src="jquery-1.4.4.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('a').click(function() {
$('div').toggle();
});
});
</script>
</head>
<body>
<a href="#" onclick="alert('original onclick')">Click me</a>
<div>
Some div content...
</div>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.