Blogger Information
Blog 42
fans 0
comment 1
visits 25997
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
关于jQuery两种引入方式及$(document).ready使用及简写方式-2018年4月3日上午11:23完成
邵军-山东-84918的博客
Original
1777 people have browsed it

jQuery本地引入:

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>jQuery本地引入</title>
    <script type="text/javascript" src="./js/jquery-3.3.1.js"></script>

</head>

<body>
<h2>点击我会弹出欢迎对话框</h2>
<script type="text/javascript">
     $('h2').click(function(){
        alert('欢迎您!')
     })
</script>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

jQuery外部引入:

实例

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <title>jQuery外部引入</title>
    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>

<body>
    <h2>点击我会弹出欢迎对话框</h2>
    <script type="text/javascript">
    $('h2').click(function() {
        alert('欢迎您!')
    })
    </script>
</body>

</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

$(document).ready使用方式学习:

实例

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <title>$(document).ready使用方式学习</title>
    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
        $("h2").click(function() {
            alert("hello!")
        })

    })
    </script>
</head>

<body>
    <h2>点击我会弹出欢迎对话框</h2>
</body>

</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

$(document).ready简写使用方式学习:

实例

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <title>$(document).ready简写使用方式学习</title>
    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script type="text/javascript">
    $(function() {
        $("h2").click(function() {
            alert("hello!")

        })
    })
    </script>
</head>

<body>
    <h2>点击我会弹出欢迎对话框</h2>
</body>

</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

学习总结:

1、内容比较简单,要注意拼写方式,否则易出错误;

2、$(document).ready很方便,减少了大量代码的输入。

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post