简体   繁体   English

为什么单击按钮时脚本不起作用?

[英]Why scripts don't work when I click on a button?

I have a button which when user click on it, phone numbers will be appear slowly.我有一个按钮,当用户点击它时,电话号码会慢慢出现。

Here is the HTML Codes:这是 HTML 代码:

<span id="show-phone-numbers" href="#tab4" data-bs-toggle="tab" class="btn btn-success">
   <i class="fe fe-phone-call"></i> Show Phone Number
</span> 

<div class="media margin-top-20" id="phone-number-section" style="display:none">
    <div class="media-body text-center">

         <a href="tel:00000000">
             <p class="btn btn-outline-primary">
                  <i class="fe fe-phone-call"></i>    somephonenumber
             </p>
         </a>
                                                    

         <a href="tel:00000000">
             <p class="btn btn-outline-primary">
                  <i class="fe fe-phone-call"></i>    somephonenumber
             </p>
         </a>
                                                
     </div>
</div>

And here is the scripts:这是脚本:

$("#show-phone-numbers").on("click",function(){
    $("#phone-number-section").toggle("slow");
});

The problem is when I click on the "Show Phone Number" button, I get this error in the console:问题是当我单击“显示电话号码”按钮时,我在控制台中收到此错误:

enter image description here在此处输入图像描述

And (bootstrap-rtl.js:1031:35) is the code below:并且(bootstrap-rtl.js:1031:35)是下面的代码:

children(element, selector) {
  return [].concat(...element.children).filter(child => child.matches(selector));
},

I did search about the error but I couldn't find a way which help me to handle this error.我确实搜索了该错误,但找不到帮助我处理此错误的方法。

Why do you have data-bs-toggle="tab" in there, without any bootstrap tab elements?为什么你有data-bs-toggle="tab"在那里,没有任何引导选项卡元素? This causes the BS event handler to be registered, which throws this error, because it can't find properly setupped tabs.这会导致注册 BS 事件处理程序,从而引发此错误,因为它找不到正确设置的选项卡。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JS:为什么当我点击按钮时没有提示信息? - JS: why don't alert message when i click button? 为什么按钮单击在我的Javascript-html中不起作用? - Why button click don't work in my Javascript-html? 当我点击按钮时,我不知道怎么了 - I don't know what's wrong when i click the button nothing work 为什么当我单击“隐藏”或“显示”按钮时 label “p”不向下滑动 - why the label "p" don't slide down when i click the button "hide" or "show" 单击的Unity5按钮不起作用 - Unity5 Button on Click don't work 我不知道为什么当我在我的 HTML 程序上单击“Click = Past”按钮时,绿色字符图像不显示我在可汗学院尝试过 - I don't know why When I click the button "Click = Past" on my HTML program the green character image doesn't show up I tried to this in Khan academy 为什么我的Greasemonkey脚本无法在Chrome中运行? - Why don't my Greasemonkey scripts work in Chrome? 为什么当我单击按钮时 JQuery 代码不起作用? - Why JQuery code does not work when i click on button? 捆绑和缩小-启用的脚本不起作用时 - Bundling and minification - when enabled scripts don't work 当我点击按钮时隐藏的内容没有显示,为什么会这样? - When I click on the button the hidden content doesn't show, why is this?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM