我有这个代码:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('a.one').click(function(event){
event.preventDefault();
});
});
function test(event){
event.preventDefault();
}
</script>
<style type="text/css">
a.test { font-weight: bold; }
body { font-family:sans-serif; background-color:#AAAAAA;}
</style>
</head>
<body>
<a class="one" href="http://jquery.com/">jQuery</a>
<br/>
<a class="two" href="http://stackoverflow.com/" onclick='test(event)'>stack overflow</a>
</body>
</html>
测试函数现在无法正常工作,因为常规 javascript 事件不支持 jQuery 事件 preventDefault 函数。有什么方法可以在 jQuery 事件中包装一个常规的 javascript 事件,这样我就可以使用例如防止违约?
最佳答案
关于javascript - 我可以在 jQuery 事件中包装 javascript 事件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1796079/