jQuery的按钮点击警报问题 [英] JQuery On Button Click Alert Issue

查看:66
本文介绍了jQuery的按钮点击警报问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JSFiddle演示: https://jsfiddle.net/cr33q8v7/

JSFiddle demo: https://jsfiddle.net/cr33q8v7/

$("#findMyWeather").click(function() {
    alert("button clicked");
});

我要验证的是JQuery是否正常工作,并且没有弹出显示单击按钮的弹出窗口,因此它看起来语法错误,但是我已经对其进行了多次检查并对其进行了检查.看起来不错.

All I'm trying to verify is if the JQuery is working and I'm not getting any pop-up that says button clicked, so it would appear the syntax is wrong, but I've checked it multiple times and it looks right.

因此,如果我在JSFiddle上包含该库,那么为什么HTML文件中的以下代码不运行,因为该函数似乎是相同的,并且这些指针都直接指向该库,所以

So if I include the library on JSFiddle, then why does the below code in the HTML file not run, as it appears the function is identical and these pointers both direct to the library:

    <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
    <script>
        $("#findMyWeather").click(function() {
            alert("button clicked");
        });
    </script>

因此,//指针未引用(这是老师指示的内容).当我更改为`https:``时,它可以正常运行:

So the // pointers didn't reference (this is what the teacher instructed). When I changed to `https:``, then it functioned correctly:

    <script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
    <script src="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

我需要另一只眼睛,否则我会错过其他东西,只是看不到.

I need another set of eyes, or else I'm missing something else and just don't see it.

推荐答案

您的小提琴实际上并未通过脚本标签包含jQuery.

Your fiddle doesn't actually include jQuery via a script tag.

例如添加:<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>到您的HMTL

e.g. add: <script src="https://code.jquery.com/jquery-3.1.0.min.js"></script> to your HMTL

这篇关于jQuery的按钮点击警报问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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