<bdo id='ScMgY'></bdo><ul id='ScMgY'></ul>

    1. <i id='ScMgY'><tr id='ScMgY'><dt id='ScMgY'><q id='ScMgY'><span id='ScMgY'><b id='ScMgY'><form id='ScMgY'><ins id='ScMgY'></ins><ul id='ScMgY'></ul><sub id='ScMgY'></sub></form><legend id='ScMgY'></legend><bdo id='ScMgY'><pre id='ScMgY'><center id='ScMgY'></center></pre></bdo></b><th id='ScMgY'></th></span></q></dt></tr></i><div id='ScMgY'><tfoot id='ScMgY'></tfoot><dl id='ScMgY'><fieldset id='ScMgY'></fieldset></dl></div>

      <small id='ScMgY'></small><noframes id='ScMgY'>

      1. <legend id='ScMgY'><style id='ScMgY'><dir id='ScMgY'><q id='ScMgY'></q></dir></style></legend>
      2. <tfoot id='ScMgY'></tfoot>

        jQuery 的香草 JavaScript 版本 .click

        时间:2023-09-05
            <tbody id='UWHEP'></tbody>

            <small id='UWHEP'></small><noframes id='UWHEP'>

              <bdo id='UWHEP'></bdo><ul id='UWHEP'></ul>
              <legend id='UWHEP'><style id='UWHEP'><dir id='UWHEP'><q id='UWHEP'></q></dir></style></legend>

                <i id='UWHEP'><tr id='UWHEP'><dt id='UWHEP'><q id='UWHEP'><span id='UWHEP'><b id='UWHEP'><form id='UWHEP'><ins id='UWHEP'></ins><ul id='UWHEP'></ul><sub id='UWHEP'></sub></form><legend id='UWHEP'></legend><bdo id='UWHEP'><pre id='UWHEP'><center id='UWHEP'></center></pre></bdo></b><th id='UWHEP'></th></span></q></dt></tr></i><div id='UWHEP'><tfoot id='UWHEP'></tfoot><dl id='UWHEP'><fieldset id='UWHEP'></fieldset></dl></div>

                1. <tfoot id='UWHEP'></tfoot>
                2. 本文介绍了jQuery 的香草 JavaScript 版本 .click的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  所以也许我只是没有在正确的地方寻找,但我找不到一个很好的解释来说明如何做相当于 jQuery 的操作

                  So maybe I'm just not looking in the right places but I can't find a good explanation of how to do the equivalent of jQuery's

                  $('a').click(function(){
                      // code here
                  });
                  

                  在普通的旧 JavaScript 中?

                  in plain old JavaScript?

                  基本上我想在每次单击 a 标记时运行一个函数,但我没有能力将 jQuery 加载到页面中以按上述方式执行此操作,所以我需要知道如何使用纯 JavaScript 来做到这一点.

                  Basically I want to run a function every time an a tag is clicked but I don't have the ability to load jQuery into the page to do it in the way above so I need to know how to do it using plain JavaScript.

                  推荐答案

                  工作示例:http://jsfiddle.net/6ZNws/

                  HTML

                  <a href="something">CLick Here</a>
                  <a href="something">CLick Here</a>
                  <a href="something">CLick Here</a>
                  

                  Javascript:

                  Javascript:

                  var anchors = document.getElementsByTagName('a');
                  for(var z = 0; z < anchors.length; z++) {
                      var elem = anchors[z];   
                      elem.onclick = function() {
                          alert("hello");
                          return false;
                      };
                  }
                  

                  这篇关于jQuery 的香草 JavaScript 版本 .click的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:添加多个 onload 处理程序 下一篇:Jquery/JS 绑定“粘贴"输入文本框的事件处理程

                  相关文章

                  最新文章

                  1. <tfoot id='YaVP7'></tfoot>
                    <i id='YaVP7'><tr id='YaVP7'><dt id='YaVP7'><q id='YaVP7'><span id='YaVP7'><b id='YaVP7'><form id='YaVP7'><ins id='YaVP7'></ins><ul id='YaVP7'></ul><sub id='YaVP7'></sub></form><legend id='YaVP7'></legend><bdo id='YaVP7'><pre id='YaVP7'><center id='YaVP7'></center></pre></bdo></b><th id='YaVP7'></th></span></q></dt></tr></i><div id='YaVP7'><tfoot id='YaVP7'></tfoot><dl id='YaVP7'><fieldset id='YaVP7'></fieldset></dl></div>

                        <bdo id='YaVP7'></bdo><ul id='YaVP7'></ul>

                      <small id='YaVP7'></small><noframes id='YaVP7'>

                    1. <legend id='YaVP7'><style id='YaVP7'><dir id='YaVP7'><q id='YaVP7'></q></dir></style></legend>