JQuery 中幾個(gè)類(lèi)選擇器的簡(jiǎn)單使用介紹
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestClassSelector.aspx.cs" Inherits="WebApplication1.TestClassSelector" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.9.0.min.js"></script>
<style type="text/css">
.first_div {
background-color:red;
}
.second_div {
background-color:green;
}
.first_span {
width:500px;
height:100px;
}
.eric_sun_class {
font-family:Arial;
font-size:18px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="first_div">
This is the first div
</div>
<div class="second_div">
This is the second div
</div>
<div class="first_div">
<span class="first_span">
This is the first span
</span>
</div>
<span class="first_span eric_sun_class">
This is the first span + eric sun class.
</span>
<br />
<span class="eric_sun_class">
This is the eric sun class.
</span>
<br />
<input type="button" value="Test" onclick="btn_Click();" />
</div>
</form>
</body>
</html>
<script type="text/javascript">
function btn_Click() {
alert($(".first_div").text());
alert($(".first_div.first_span").text());
}
</script>
$(".first_div, .first_span")
將包含有.first_div 或者 .first_span" 的對(duì)象都取到。 這里取到 4 個(gè) 對(duì)象。
此處的Html對(duì)應(yīng)
<div class="first_div">
This is the first div
</div>
<div class="first_div">
<span class="first_span">
This is the first span
</span>
</div>
<span class="first_span eric_sun_class">
This is the first span + eric sun class.
</span>
$(".first_div .first_span")
將以 .first_div 為類(lèi)的控件 下的 以 .first_span 為類(lèi) 的對(duì)象取到(類(lèi)與類(lèi)之間帶有空格 逐層取)。 這里只取到 1 個(gè)。
對(duì)應(yīng)的 className="first_span" 此處的Html對(duì)應(yīng)
<div class="first_div">
<span class="first_span">
This is the first span
</span>
</div>
$(".first_span.eric_sun_class")
將包含有.first_span 并且同時(shí)包含有 .eric_sun_class 類(lèi)的 對(duì)象取到(類(lèi)與類(lèi)之間沒(méi)有空格 類(lèi)似于 ‘與' 操作)。 這里只取到1個(gè)。
對(duì)應(yīng)的 className="first_span eric_sun_class" 此處的Html 對(duì)應(yīng)
<span class="first_span eric_sun_class">
This is the first span + eric sun class.
</span>
- jQuery類(lèi)選擇器用法實(shí)例
- 使用jquery選擇器如何獲取父級(jí)元素、同級(jí)元素、子元素
- jquery選擇器之屬性過(guò)濾選擇器詳解
- jquery 中多條件選擇器,相對(duì)選擇器,層次選擇器的區(qū)別
- jQuery Selector選擇器小結(jié)
- Jquery選擇器中使用變量實(shí)現(xiàn)動(dòng)態(tài)選擇例子
- JQuery中$之選擇器用法介紹
- Jquery顏色選擇器ColorPicker實(shí)現(xiàn)代碼
- jQuery過(guò)濾選擇器:not()方法使用介紹
- jquery 屬性選擇器(匹配具有指定屬性的元素)
- jquery選擇器大全 全面詳解jquery選擇器
- jQuery中的類(lèi)名選擇器(.class)用法簡(jiǎn)單示例
相關(guān)文章
基于JQuery實(shí)現(xiàn)圖片上傳預(yù)覽與刪除操作
這篇文章主要為大家詳細(xì)介紹了基于JQuery實(shí)現(xiàn)圖片上傳預(yù)覽與刪除操作的相關(guān)代碼,感興趣的小伙伴們可以參考一下2016-05-05基于jquery實(shí)現(xiàn)的圖片在各種分辨率下未知的容器內(nèi)上下左右居中
這篇文章主要介紹了基于jquery實(shí)現(xiàn)的圖片在各種分辨率下未知的容器內(nèi)上下左右居中的方法,需要的朋友可以參考下2014-05-05jquery中l(wèi)oad方法的用法及注意事項(xiàng)說(shuō)明
本篇文章主要是對(duì)jquery中l(wèi)oad方法的用法及注意事項(xiàng)進(jìn)行了詳細(xì)介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2014-02-02jQuery使用動(dòng)畫(huà)隊(duì)列自定義動(dòng)畫(huà)操作示例
這篇文章主要介紹了jQuery使用動(dòng)畫(huà)隊(duì)列自定義動(dòng)畫(huà)操作,涉及jQuery使用queue()方法和dequeue()方法進(jìn)行函數(shù)隊(duì)列操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2018-06-06jquery 動(dòng)態(tài)創(chuàng)建元素的方式介紹及應(yīng)用
動(dòng)態(tài)創(chuàng)建元素可以通過(guò)兩種方式1、Dom HTml2、JQuery函數(shù)創(chuàng)建3、頁(yè)面加載的時(shí)候最好在頁(yè)面加載完后執(zhí)行創(chuàng)建,感興趣的朋友可以了解下2013-04-04jQuery實(shí)現(xiàn)TAB選項(xiàng)卡切換特效簡(jiǎn)單演示
這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)TAB選項(xiàng)卡切換特效簡(jiǎn)單演示,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-03-03jquery ajax雙擊div可直接修改div中的內(nèi)容
這篇文章主要介紹了jquery ajax雙擊div直接修改div中內(nèi)容的相關(guān)方法,感興趣的小伙伴們可以參考一下2016-03-03jQuery 遍歷- 關(guān)于closest() 的方法介紹以及與parents()的方法區(qū)別分析
本篇文章介紹了,jQuery 遍歷- 關(guān)于closest() 的方法介紹以及與parents()的方法區(qū)別分析。需要的朋友參考下2013-04-04JQuery實(shí)現(xiàn)ajax請(qǐng)求的示例和注意事項(xiàng)
今天小編就為大家分享一篇關(guān)于JQuery實(shí)現(xiàn)ajax請(qǐng)求的示例和注意事項(xiàng),小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2018-12-12