<legend id='TlECK'><style id='TlECK'><dir id='TlECK'><q id='TlECK'></q></dir></style></legend>

    1. <small id='TlECK'></small><noframes id='TlECK'>

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

        只定义了函数,但无论如何都会立即执行

        Function only defined but immediately executed anyway(只定义了函数,但无论如何都会立即执行)

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

                <bdo id='0d6uq'></bdo><ul id='0d6uq'></ul>
              • <small id='0d6uq'></small><noframes id='0d6uq'>

                    <tbody id='0d6uq'></tbody>

                  本文介绍了只定义了函数,但无论如何都会立即执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的文件 ajaxrequest.js 中有一段简短的 javascript 代码有问题.这里是:

                  I'm having trouble with a short javascript code in my file ajaxrequest.js . Here it is :

                  function afficher () {
                    $.post('requete_affichage.php', function (data) {
                      $('#name-data').text(data); });
                  }
                  
                  $('#bouton2').on('click', afficher());
                  

                  所以问题是,只要我在浏览器中点击localhost",该函数就会立即执行并将数据插入到我的 index.html 页面的 div#name-data 字段中,而不是等待我点击#bouton2 这样做.有什么想法吗?

                  So the problem is the function immediately executes and inserts the data in the div#name-data field of my index.html page as soon as i hit "localhost" in my browser, and doesn't wait for my click on #bouton2 to do so. Any idea ?

                  推荐答案

                  通过在函数后面加上方括号,您可以告诉它立即执行.要将函数引用分配给单击处理程序,请删除括号:

                  By including the brackets after the function you are telling it to execute immediately. To assign the function reference to the click handler, remove the brackets:

                  $('#bouton2').on('click', afficher);
                  

                  这篇关于只定义了函数,但无论如何都会立即执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

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

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

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

                            <tbody id='KafIO'></tbody>

                            <legend id='KafIO'><style id='KafIO'><dir id='KafIO'><q id='KafIO'></q></dir></style></legend>