Blogger Information
Blog 56
fans 3
comment 1
visits 50812
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
jquery导入方式——2018年4月3日7时30分
沈斌的博客
Original
696 people have browsed it

jquery两种导入方式:


实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>jquery import</title>
    <style media="screen">
        .list {
            float: left;
            list-style-type: none;
            background-color: lightskyblue;
            font-weight: bold;
            margin: 10px;
        }

        .order {
            margin: 0;
            padding: 0;
        }
    </style>
    <!-- 本地文件导入 -->
    <script type="text/javascript" src="./js/jquery-3.3.1.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $('ul>li').addClass('list')
        })

        // 简写
        $(function () {
            $('ul').addClass('order')
        })
    </script>
</head>
<body>
    <h2>jquery</h2>
    <ul>
        <li>iphone</li>
        <li>samsung</li>
        <li>huawei</li>
    </ul>
</body>
</html>

<!-- cdn导入 -->
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
    $('h2').click(function (){
        alert('www.baidu.com')
    })
    var title=$('<span>2018.4.2</span>')
    title.insertAfter('h2').css('color','lightgreen')
</script>

运行实例 »

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

jQuery导入有两种方式:cdn导入和本地导入,cdn导入方式比较方便。在<head>中执行jQuery,使用$(document).ready(function(){}),也可以简写为$(function(){}).

jquery.png

Correction status:Uncorrected

Teacher's comments:
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