色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

JQuery 學習筆記 選擇器之五

復制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/jquery-1.3.2.js"></script>
<script type="text/Javascript"><!--
    $(function(){
            $("#aFirst").click(function(){
                    $("div[id]").each(function(){
                        $(this).css("background","#773300");
                    })
            })
            $("#aSecond").click(function(){
                    $("div[id = div2]").each(function(){
                         $(this).css("background","#8833ff");
                    })
            })
            $("#aThird").click(function(){
                    $("div[id != div2]").each(function(){
                         $(this).css("background","#87f289");
                    })
            })
            $("#aFourthly").click(function(){
                    $("div[name ^= DIV]").each(function(){
                         $(this).css("background","#140586");
                    })
            })
            $("#aFifthly").click(function(){
                    $("div[name $= ly]").each(function(){
                         $(this).css("background","#930584");
                    })
            })
            $("#aSixth").click(function(){
                    $("div[name *= th]").each(function(){
                         $(this).css("background","#099483");
                    })
            })
            $("#aSeventh").click(function(){
                    $("div[id][name !=Fifthly][name *= i]").each(function(){
                         $(this).css("background","#938607");
                    })
            })
     })
// --></script>
<title>無標題文檔</title>
</head>
<body>
<a href="#" onclick="Javascript:location.reload();">重置</a>
<div id="div1" name ="DIV_First">div1</div>
<div id="div2" name ="DIV_Second">div2</div>
<div id="div3" name = "DIV_Third">div3</div>
<div id="div4" name = "DIV_Fourthly">div4</div>
<div id="div5" name="Fifthly">div5</div>

<a href="#" id="aFirst">設置頁面所有DIV元素的背景顏色</a>|
<a href="#" id="aSecond">設置第2個DIV的背景顏色</a>|
<a href="#" id="aThird">設置除第2個DIV以外DIV的背景顏色</a>|
<a href="#" id="aFourthly">設置name屬性值以DIV開頭的元素</a>|
<a href="#" id="aFifthly">設置name屬性值以ly結尾的元素</a>|
<a href="#" id="aSixth">設置name屬性值包含th的元素</a>|
<a href="#" id="aSeventh">綜合應用</a>

</body>
</html>

1.$("selector [Attribute]")--注,以下直接簡寫為[Attribute]
描述:獲取selector選擇的元素集合里,擁有Attribute屬性的元素集合。應該較為簡單,在這就不做啥詳細說明了,有不了解的跟下貼,哈
返回值:Array(Element);
2.[attribute=value]
描述:獲取selector選擇的元素集合里,擁有Attribute屬性值等于Value的元素集合。
返回值:Array(Element);
3.[attribute!=value]
描述:獲取selector選擇的元素集合里,擁有Attribute屬性值不等于Value的元素集合。
返回值:Array(Element);
4.[attribute^=value]
描述:獲取selector選擇的元素集合里,擁有Attribute屬性值以Value開頭的元素集合。相當于正則的規范^^
返回值:Array(Element);
5.[attribute$=value]
描述:獲取selector選擇的元素集合里,擁有Attribute屬性值以Value結尾的元素集合。相當于正則的規范^^
返回值:Array(Element);
6.[attribute*=value]
描述:獲取selector選擇的元素集合里,擁有Attribute屬性值包含Value的元素集合。
返回值:Array(Element);
7.[selector1][selector2][selectorN]
描述:與第一章中,基本選擇器綜合應用一樣,此方法也就是前6種的綜合版,就如我例子中$("div[id][name !=Fifthly][name *= i]")就是取所有的div元素中,擁有ID屬性&&name屬性!=Fifthly&&name屬性包含字符i的DIV元素的集合,大家用我例子試下就能很清楚的了解看到效果了,哈。好好利用此方法應該很有用^^
返回值:Array(Element);

JavaScript技術JQuery 學習筆記 選擇器之五,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 长岛县| 凉山| 城口县| 梁山县| 阿鲁科尔沁旗| 巍山| 峨眉山市| 马鞍山市| 财经| 罗田县| 轮台县| 乌拉特中旗| 略阳县| 瑞丽市| 弋阳县| 十堰市| 和林格尔县| 新乡县| 新营市| 霞浦县| 茂名市| 博湖县| 黄大仙区| 东源县| 京山县| 东明县| 稷山县| 泸水县| 康马县| 高淳县| 潍坊市| 定兴县| 普宁市| 古浪县| 青川县| 措美县| 内黄县| 财经| 长兴县| 茶陵县| 阳曲县|