为什么我的onclick事件没有在Firefox中注册? [英] Why is my onclick event not registered in Firefox?
问题描述
我有一个包含 onclick
事件的列表项。它运行在Chrome和Internet Explorer中,但不是Firefox。有什么建议吗?
$ p $ < li onclick =alert('test');> test test< br>< /立GT;
>
选中此项:
-
您的浏览器已启用JavaScript。 >
-
尝试在标签中添加
return false;
语句。 b
或者像这样的函数:
$ $ p $function test() {
//你的代码在这里
返回false;
$ / code>
- 或者使用这个:
JavaScript is enabled in your browser.
Try adding a
return false;
statement in your tag.- Or use this:
< a href =#onclick =alert('hi');>链接< / a>
或这个
< a href = javascript:void(0)onclick =alert('hi');> Link< / a>
I have a list item with an
onclick
event. It runs in Chrome and Internet Explorer, but not Firefox. Any suggestions?<li onclick="alert('test');">test test<br></li>
解决方案This works fine for me in Firefox.
Check this:
Or a function like this:
function test() { //your code here return false; }
<a href="#" onclick="alert('hi');">Link</a>
or this
<a href="javascript:void(0)" onclick="alert('hi');">Link</a>
这篇关于为什么我的onclick事件没有在Firefox中注册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!