• 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>

     

  • 相关阅读:
    鼠标不灵了,还好只是线的问题。自己DIY修下了
    [摘]编译MPlayer
    TPLINK路由器 硬重启方法
    Visual C++线程同步技术剖析 (转载)
    CListCtrl一行显示多个图标问题
    一位软件工程师的6年总结
    CCIE红头发讲解CCNA、CCNP视频教程
    图片链
    [摘]如何级联两个TPLINK路由器
    [摘]测试一下你对IP地址的掌握水平
  • 原文地址:https://www.cnblogs.com/semcoding/p/3287352.html
Copyright © 2020-2023  润新知