美文网首页
使用jQuery-mobil-周国康笔记

使用jQuery-mobil-周国康笔记

作者: ZGKzm | 来源:发表于2016-08-17 08:20 被阅读0次

    使用jquery mobil

    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css">
    <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>

    
    ### jquery 选择器
    >```
    jQuery 选择器
    关键点是学习 jQuery 选择器是如何准确地选取您希望应用效果的元素。
    jQuery 元素选择器和属性选择器允许您通过标签名、属性名或内容对 HTML 元素进行选择。
    选择器允许您对 HTML 元素组或单个元素进行操作。
    在 HTML DOM 术语中:
    选择器允许您对 DOM 元素组或单个 DOM 节点进行操作。
    jQuery 元素选择器
    jQuery 使用 CSS 选择器来选取 HTML 元素。
    $("p") 选取 <p> 元素。
    $("p.intro") 选取所有 class="intro" 的 <p> 元素。
    $("p#demo") 选取所有 id="demo" 的 <p> 元素。
    jQuery 属性选择器
    jQuery 使用 XPath 表达式来选择带有给定属性的元素。
    $("[href]") 选取所有带有 href 属性的元素。
    $("[href='#']") 选取所有带有 href 值等于 "#" 的元素。
    $("[href!='#']") 选取所有带有 href 值不等于 "#" 的元素。
    $("[href$='.jpg']") 选取所有 href 值以 ".jpg" 结尾的元素。
    jQuery CSS 选择器
    jQuery CSS 选择器可用于改变 HTML 元素的 CSS 属性。
    下面的例子把所有 p 元素的背景颜色更改为红色:
    实例
    $("p").css("background-color","red");
    

    语法 描述

    $(this) 当前 HTML 元素
    $("p") 所有 <p> 元素
    $("p.intro") 所有 class="intro" 的 <p> 元素
    $(".intro") 所有 class="intro" 的元素
    $("#intro") id="intro" 的元素
    $("ul li:first") 每个 <ul> 的第一个 <li> 元素
    $("[href$='.jpg']") 所有带有以 ".jpg" 结尾的属性值的 href 属性
    $("div#intro .head") id="intro" 的 <div> 元素中的所有 class="head" 的元素

    
    ### $(this).hide()
    >```
    <html>
    <head>
    <script type="text/javascript" src="/jquery/jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
      $("button").click(function(){
      $(this).hide();
    });
    });
    </script>
    </head>
    <body>
    <button type="button">Click me</button>
    </body>
    </html>
    

    $("#test").hide()

    <html>
    <head>
    <script type="text/javascript" src="/jquery/jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $("button").click(function(){
    $("#test").hide();
    });
    });
    </script>
    </head>
    <body>
    <h2>This is a heading</h2>
    <p>This is a paragraph.</p>
    <p id="test">This is another paragraph.</p>
    <button type="button">Click me</button>
    </body>
    </html>

    
    ### $("p").hide()
    >```
    <html>
    <head>
    <script type="text/javascript" src="/jquery/jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $("button").click(function(){
    $("p").hide();
    });
    });
    </script>
    </head>
    <body>
    <h2>This is a heading</h2>
    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>
    <button type="button">Click me</button>
    </body>
    </html>
    

    $(".test").hide()

    <html>
    <head>
    <script type="text/javascript" src="/jquery/jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function()
    {
    $("button").click(function()
    {
    $(".test").hide();
    });
    });
    </script>
    </head>
    <body>
    <h2 class="test">This is a heading</h2>
    <p class="test">This is a paragraph.</p>
    <p>This is another paragraph.</p>
    <button type="button">Click me</button>
    </body>
    </html>

    相关文章

      网友评论

          本文标题:使用jQuery-mobil-周国康笔记

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