zoukankan      html  css  js  c++  java
  • jquery1.9学习笔记 之选择器(基本元素四)

    ID选择器("#id")

     

    描述: 选择与给出ID属性匹配的单元标签。

           对于ID选择器,jquery使用JS的函数document.getElementById(),当一个标签附加到ID选择器上时,也是非常有效的。如h2#pageTitlejquery会在识别元素标签前进行检查以做出匹配。

     

     

    例子:  

    <!doctype html>

    <html>

      <head>

        <meta charset='utf-8'>

        <title>id demo</title>

        <style>

          div{

            90px;

            height: 90px;

            float: left;

            padding:5px;

            margin:5px;

            background-color:#EEEEEE;

          }

        </style>

        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>

      </head>

      <body>

        <div id='notMe'><p>id='notMe'</p></div>

        <div id='myDiv'>id='myDiv'</div>

        <script type="text/javascript">

          $('#myDiv').css('border', '3px solid red');

        </script>

      </body>

    </html>

    例:

    针对ID中的一些特殊字符,要使用反斜线进行转义

    <!doctype html>

    <html lang='zh'>

      <head>

          <meta charset='utf-8'>

          <title>id demo</title>

          <style type="text/css">

              div{

                  300px;

                  float:left;

                  padding:2px;

                  margin:3px;

                  background-color:#EEEEEE;

              }

          </style>

          <script src="http://code.jquery.com/jquery-1.9.1.js"></script>

      </head>

      <body>

          <div id='myID.entry[0]'>id='myID.entry[0]'</div>

          <div id='myID.entry[1]'>id='myID.entry[1]'</div>

          <div id='myID.entry[2]'>id=''myID.entry[2]'</div>

          <script type="text/javascript">

              $("#myID\.entry\[1\]").css("border", "3px solid red");

          </script>

      </body>

    </html>

  • 相关阅读:
    Codeforces Round #599 (Div. 2) B2. Character Swap (Hard Version) 构造
    Codeforces Round #598 (Div. 3) F Equalizing Two Strings(构造题)
    codeforces round # 384 div2 B Chloe and the sequence 神奇二进制找规律题
    codeforces round #384 div2 C Vladik and fractions(构造)
    线段树板子
    Codeforces Round #616 (Div. 2) D (找规律题)
    codeforces round #616 div2 A (Even but not even)水题
    2017的计划清单
    回顾2016,我的简单总结
    关于ubuntu下sublime text 3 的安装和中文配置问题
  • 原文地址:https://www.cnblogs.com/semcoding/p/3293404.html
Copyright © 2011-2022 走看看