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

    类选择器(".class")

     描述: 选择所有与给出类匹配的元素

           对于类选择器来说,jquery使用的是javascript原生的方法getElementByClassName()

    例子:

    <!doctype html>

    <html lang='zh'>

      <head>

          <meta charset="utf-8">

          <title>class demo</title>

          <style type="text/css">

              div, span{

                 120px;

                height: 40px;

                float: left;

                padding: 10px;

                margin: 10px;

                background-color: #EEEEEE;

              }

          </style>

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

      </head>

      <body>

          <div class="notMe">div class="notMe"</div>

          <div class="myClass">div class="myClass"</div>

          <span class="myClass">span class="myClass"</span>

          <script>

            $(".myClass").css("border", "3px solid red");

          </script>

      </body>

    </html>

     

     

    例子:查找同时含有myclass 和 otherclass 类的元素。

    <!doctype html>

    <html lang="zh">

      <head>

        <meta charset='utf-8'>

        <title>class demo</title>

        <style type="text/css">

          div,span{

            120px;

            height:40px;

            padding:10px;

            margin:10px;

            background-color:#EEEEEE;

            float: left;

          }

        </style>

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

      </head>

      <body>

          <div class="myclass">div class='myclass'</div>

          <div class="myclass otherclass">div class="myclass otherclass"</div>

          <span class="myclass otherclass">span class="myclass otherclass"</span>

          <script type="text/javascript">

            $(".myclass.otherclass").css("border", "13px solid red");

          </script>

      </body>

    </html>

     

  • 相关阅读:
    RUST实践.md
    redis.md
    opencvrust.md
    aws rds can't connect to mysql server on 'xx'
    Foundation ActionScript 3.0 With Flash CS3 And Flex
    Foundation Flash Applications for Mobile Devices
    Flash Mobile Developing Android and iOS Applications
    Flash Game Development by Example
    Actionscript 3.0 迁移指南
    在SWT中非UI线程控制界面
  • 原文地址:https://www.cnblogs.com/semcoding/p/3287352.html
Copyright © 2011-2022 走看看