美文网首页
js 使用jquery

js 使用jquery

作者: 老魏313 | 来源:发表于2017-12-02 23:06 被阅读0次
    1. 引入jQuery 问题
    • 引入下载好的jQuery文件
    <script src="jquery-3.2.1.js"></script>
    
    • 引入谷歌
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js">
    
    • 引入Microsoft CDN:
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js">
    
    2. 点击隐藏内容
     <script>
            // 隐藏按钮
            function clickButton(button) {
                $(button).hide();
            }
      </script>
    <input type="button" id="button" onclick="clickButton(this)" value="点我隐藏">
    
    3. 按id 修改内容
        <script>
            // 修改值
            function myfunction() {
                $("#hhh").html("habcknal");
            }
            $(document).ready(myfunction);  // 页面加载完成后调用该方法
        </script>
    <h3 id="hhh"></h3>
    
    4.语法
    $(this).hide();   // 隐藏当前元素
    $("p").hide();  //隐藏所有段落
    $(".test").hide(); // 隐藏所有 class="test" 的所有元素
    $("#test").hide();  //隐藏所有 id="test" 的元素
    
    5.选择器实例
    图片.png
    6.

    相关文章

      网友评论

          本文标题:js 使用jquery

          本文链接:https://www.haomeiwen.com/subject/xdtfextx.html