为什么我的onclick事件没有在Firefox中注册? [英] Why is my onclick event not registered in Firefox?

查看:191
本文介绍了为什么我的onclick事件没有在Firefox中注册?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含 onclick 事件的列表项。它运行在Chrome和Internet Explorer中,但不是Firefox。有什么建议吗?

$ p $ < li onclick =alert('test');> test test< br>< /立GT;


解决方案

>

选中此项:


  1. 您的浏览器已启用JavaScript。 >


  2. 尝试在标签中添加 return false; 语句。 b

    或者像这样的函数:

    $ $ p $ function test() {
    //你的代码在这里
    返回false;

    $ / code>




    1. 或者使用这个:



    2. < 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:

      1. JavaScript is enabled in your browser.

      2. Try adding a return false; statement in your tag.

      Or a function like this:

      function test() {
          //your code here
          return false;
      }
      

      1. Or use this:

      <a href="#" onclick="alert('hi');">Link</a>

      or this

      <a href="javascript:void(0)" onclick="alert('hi');">Link</a>

      这篇关于为什么我的onclick事件没有在Firefox中注册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆