• [ jquery 属性选择器[key |= val] ] 此方法选取与给定表达式相匹配的元素


    建议在观看学习本章之前有一定css选择器和正则表达式语法基础,这样不必死记硬背会好理解一点:

    实例:

    <!DOCTYPE html>
    <html lang='zh-cn'>
    <head>
    <title>Insert you title</title>
    <meta http-equiv='description' content='this is my page'>
    <meta http-equiv='keywords' content='keyword1,keyword2,keyword3'>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type='text/javascript' src='./js/jquery-1.12.1.min.js'></script>
    <style type='text/css'>
        *{margin:0;padding:0;}
        #wrap{800px;height:450px;margin:20px auto;}
        input{text-indent:8px;font:400 13px/1.2em 'Courier New';color:#999;99%;margin:5px 0;padding:8px 0;box-sizing:border-box;}
        .newClass{text-decoration: line-through; }
    </style>
    <script type='text/javascript'>
        $(function(){
            
            // 使用   [key = val] 并结合其他选择器实现对元素精确选取
            $('input[type="text"]').val('userName');
            
            // 使用   [key] 并结合其他选择器实现对元素精确选取
            $('input[type]').css('letter-spacing','1px');
            
             // 使用   [key != val] 并结合其他选择器实现对元素精确选取
            $("input[type!='password']").addClass('newClass');
            
            // 使用   [key ^= val] 并结合其他选择器实现对元素精确选取
            $('#target a[href ^= "http://"').css({'text-decoration':'none','color':'#333','font':'400 16px/1.2em "Courier New"','cursor':'pointer',});
            
            // 使用   [key $= val] 并结合其他选择器实现对元素精确选取
            $('#target a[href $= "hk"').css({'text-decoration':'line-through','color':'#666','font':'400 16px/1.2em "Courier New"','cursor':'pointer',});
            
            // 使用   [key *= val] 并结合其他选择器实现对元素精确选取
            $('#target a[href *= ".com"').css({'display':'inline-block','background':'GreenYellow','width':'49%','text-align':'center','height':'20px','font':'400 16px/20px "Courier New"',});
        });
    </script>
    </head>
    <body>
        <div id='wrap'>
            <form id='form'>
                <input type='text' id='user' placeholder='user'/>
                <input type='password' id='pw'/>
            </form>
            <div id='target'>
                <a href='http://www.baidu.com' target='_blank'>baidu</a>
                <a href='https://www.goggle.com.hk' target='_blank'>goggle</a>
            </div>
        </div>
        
    </body>
    </html>
  • 相关阅读:
    枚举
    log4j 简单应用
    [luogu4728 HNOI2009] 双递增序列 (dp)
    [luogu3760 TJOI2017] 异或和(树状数组)
    [luogu1485 HNOI2009] 有趣的数列 (组合数学 卡特兰数)
    [luogu4054 JSOI2009] 计数问题(2D BIT)
    [luogu2594 ZJOI2009]染色游戏(博弈论)
    [luogu2591 ZJOI2009] 函数
    [luogu2148 SDOI2009] E&D (博弈论)
    [luogu2154 SDOI2009] 虔诚的墓主人(树状数组+组合数)
  • 原文地址:https://www.cnblogs.com/mysearchblog/p/5606782.html
Copyright © 2020-2023  润新知