zoukankan      html  css  js  c++  java
  • .is() 检查当前的配套与选择器,jQuery对象的元素,或返回TRUE如果在这些元素的至少一个匹配给定的参数。

    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>is demo</title>
    <style>
    div {
     60px;
    height: 60px;
    margin: 5px;
    float: left;
    border: 4px outset;
    background: green;
    text-align: center;
    font-weight: bolder;
    cursor: pointer;
    }
    .blue {
    background: blue;
    }
    .red {
    background: red;
    }
    span {
    color: white;
    font-size: 16px;
    }
    p {
    color: red;
    font-weight: bolder;
    background: yellow;
    margin: 3px;
    clear: left;
    display: none;
    }
    </style>
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    </head>
    <body>
    <div></div>
    <div class="blue"></div>
    <div></div>
    <div class="red"></div>
    <div><br/><span>Peter</span></div>
    <div class="blue"></div>
    <p> </p>
    <script>
    $( "div" ).one( "click", function() {
    if ( $( this ).is( ":first-child" ) ) {
    $( "p" ).text( "It's the first div." );
    } else if ( $( this ).is( ".blue,.red" ) ) {
    $( "p" ).text( "It's a blue or red div." );
    } else if ( $( this ).is( ":contains('Peter')" ) ) {
    $( "p" ).text( "It's Peter!" );
    } else {
    $( "p" ).html( "It's nothing <em>special</em>." );
    }
    $( "p" ).hide().slideDown( "slow" );
    $( this ).css({
    "border-style": "inset",
    cursor: "default"
    });
    });
    </script>
    </body>
    </html>
    <br>
    <a href="http://api.jquery.com/is/">原文地址</a>
    
  • 相关阅读:
    Gym
    UVALive
    UVALive
    UVALive
    UVALive
    Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset Trie
    HDU 5816 Hearthstone 概率dp
    欧几里德与扩展欧几里德算法(转)
    差分约束系统详解(转)
    2016年第七届蓝桥杯C/C++程序设计本科B组决赛
  • 原文地址:https://www.cnblogs.com/flying-tx/p/3854113.html
Copyright © 2011-2022 走看看