JavaScript js 引入CDN 不生效 注意事項

【博客園cnblogs筆者m-yb原創,轉載請加本文博客連接,筆者github: https://github.com/mayangbo666,公衆號aandb7,QQ羣927113708】
https://www.cnblogs.com/m-yb/p/10075717.htmlhtml

js能夠用引入cdn替代引入js本地文件的方式, 使用一些js工具;前端

引入某個工具的cdn能夠遠程使用到js工具的函數/特性;jquery

今天博主在寫一個html引入jquery的cdn時,git

好比引入這個站點的cdn:github

staticfile // 站點ide

網站提供的是這樣的:函數

<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>工具

 

可是博主寫成了這樣:網站

<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js" />this

發現原本能用的jquery js函數不能使用了,

但願你們能注意到這點.

 

最後, 貼代碼, 樓主對前端不熟, 你們不要噴我.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>test-mayangbo666(github.com)</title>
</head>
<body>

    <p>若是你點我, 我就會消失</p>
    <p>繼續點我</p>
    <p>接着點我</p>

    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>

    <script>
        $(function () {

            $('p').click(function () {
                $(this).hide();
            })


        })
    </script>
</body>
</html>

相關文章
相關標籤/搜索