<div class="codetitle"> <span><a style="CURSOR: pointer" data="24825" class="copybut" id="copybut24825" onclick="doCopy('code24825')"><u>複製代碼</u></a></span>如下代碼:</div> <div class="codebody" id="code24825"> <br> <br> <br> <br> <br>標題> <br> <br> <br>.first_div { <br>背景顏色:紅色; <br>} <br>.second_div { <br>背景顏色:綠色; <br>} <br>.first_span { <br>寬度:500px; <br>高度:100px; font-family:Arial; <br>字體大小:18px; <br>} <br>樣式> <br>頭> <br> <br><form id=" form1" runat="server"> <br><div>; <br><div class="first_div"> <br>這是第一個div <br> </div> <br><div class=" second_div"> <br>這是第二個div <br> </div> <br><div class="first_div"> <br><span class="first_span"> <br>這是第一個跨度<br></span> <br> </div> <br><span class="first_span eric_sun_class">; <br>這是eric sun的第一堂課。 <br></span> <br><br>> <br><span class="eric_sun_class">; <br>這是 Eric Sun 的課程。 <br></span> <br><br>> <br>> <br> </div> <br> 表格> <br>身體> <br> <br> <br>function btn_Click() { <br>alert($(".first_div" ).text()); <br>alert($(".first_div.first_span").text()); <br>} <br>腳本> <br><br> <br> </form> </div> <br><div class="codetitle"> <span>複製程式碼<a style="CURSOR: pointer" data="16539" class="copybut" id="copybut16539" onclick="doCopy('code16539')"><u></u>程式碼如下:</a></span> </div>$(".first_div, .first_span") <div class="codebody" id="code16539"> <br> <br> >將包含有.first_div或者.first_span"的對像都取到。這裡取到4個對象。</div>這裡的Html對應<br><br><br><div class="codetitle"><span>複製代碼<a style="CURSOR: pointer" data="94513" class="copybut" id="copybut94513" onclick="doCopy('code94513')"> <u></u>程式碼如下:</a></span></div> <div class="first_div"> <div class="codebody" id="code94513">這是第一個div <br> </div> <br><div class=" first_div"> <br><span class="first_span"><br>這是第一個跨度<br></span> 🎜></div> <br><span class="first_span eric_sun_class"> <br><span class="first_span eric_sun_class"> <br>這是第一個span eric sun 課程<br><br> <br> <br></span></span> </div> <br><div class="codetitle">複製代碼<span><a style="CURSOR: pointer" data="34034" class="copybut" id="copybut34034" onclick="doCopy('code34034')"><u> > </u>$(".first_div .first_span") </a></span> </div> 首先.first_div 為類別的控制項,下面的以.first_span 為類別的物件取空格(類別與類別之間標示為一組層取)。 🎜>代碼如下:<div class="codebody" id="code34034"> <br> <br><div class="first_div"></div> <span class="first_span"><br>這是第一個跨度<br></span><br><div class="codetitle"><span><a style="CURSOR: pointer" data="15471" class="copybut" id="copybut15471" onclick="doCopy('code15471')"><u></u></a>複製程式碼</span></div> <div class="codebody" id="code15471">程式碼如下:<br><br> <br><br>程式碼如下:<br><br> </div> ") <br><div class="codetitle"> <span>將包含有.first_span 並且同時包含有.eric_sun_class 類別的物件取到(類別與類別之間沒有空格類似'與' 操作)。這裡只取到 1 個。 <a style="CURSOR: pointer" data="97717" class="copybut" id="copybut97717" onclick="doCopy('code97717')">對應的className ="first_span eric_sun_class" 此處的Html對應<u></u></a></span> </div>複製代碼<div class="codebody" id="code97717"> <br><br>代碼如下:</div> <br> <br> <br>這是eric sun的第一堂課。 <div class="codetitle"> <span><a style="CURSOR: pointer" data="24421" class="copybut" id="copybut24421" onclick="doCopy('code24421')"></a></span> </div> </div>