初識(shí)JQuery 實(shí)例一(first)
更新時(shí)間:2011年03月16日 23:51:02 作者:
用jquery為ul下的li依次設(shè)置樣式的代碼,主要是利用了first,next方法。
完整代碼:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.highlight
{
background-color: yellow;
}
.gray
{
background-color: Gray;
}
</style>
<script src="http://code.jquery.com/jquery-1.5.js"></script>
</head>
<body>
<ul>
<li>Look:</li>
<li>This is some text in a paragraph.</li>
<li>This is a note about it.</li>
</ul>
<script type="text/javascript">
$("ul li").first().addClass('highlight');
jQuery("ul li").first().next().addClass('gray');
</script>
</body>
</html>
復(fù)制代碼 代碼如下:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.highlight
{
background-color: yellow;
}
.gray
{
background-color: Gray;
}
</style>
<script src="http://code.jquery.com/jquery-1.5.js"></script>
</head>
<body>
<ul>
<li>Look:</li>
<li>This is some text in a paragraph.</li>
<li>This is a note about it.</li>
</ul>
<script type="text/javascript">
$("ul li").first().addClass('highlight');
jQuery("ul li").first().next().addClass('gray');
</script>
</body>
</html>
您可能感興趣的文章:
- 淺談jQuery中對(duì)象遍歷.eq().first().last().slice()方法
- jQuery中:first選擇器用法實(shí)例
- Jquery 過濾器(first,last,not,even,odd)的使用
- jQuery中eq()方法用法實(shí)例
- jQuery中toggleClass()方法用法實(shí)例
- jQuery中removeClass()方法用法實(shí)例
- jQuery中addClass()方法用法實(shí)例
- jQuery中removeProp()方法用法實(shí)例
- jQuery中prop()方法用法實(shí)例
- jQuery中first()方法用法實(shí)例
相關(guān)文章
淺談jQuery中ajaxPrefilter的應(yīng)用
下面小編就為大家?guī)?lái)一篇淺談jQuery中ajaxPrefilter的應(yīng)用。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧2016-08-08
jQuery多個(gè)input求和的實(shí)現(xiàn)方法
這篇文章主要介紹了jQuery多個(gè)input求和的實(shí)現(xiàn)方法,涉及jQuery獲取input表單元素值及運(yùn)算的相關(guān)技巧,需要的朋友可以參考下2015-02-02
JQuery學(xué)習(xí)筆錄 簡(jiǎn)單的JQuery
尺寸小、使用簡(jiǎn)單方便(Write Less, Do More,吃得少干得多,而且目前許多大公司都在支持JQuery,例如微軟,微軟把JQuery繼承在了vs2010中2012-04-04
jQuery基于隨機(jī)數(shù)解決中午吃什么去哪吃問題示例
這篇文章主要介紹了jQuery基于隨機(jī)數(shù)解決中午吃什么去哪吃問題,涉及jQuery基于事件響應(yīng)及隨機(jī)數(shù)動(dòng)態(tài)操作頁(yè)面元素相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2018-12-12
jQuery獲取checkboxlist的value值的方法
最近著手一個(gè)項(xiàng)目用到了服務(wù)器空間checkboxlist ,使用起來(lái)是方便,可以想要從js獲取值就稍微麻煩點(diǎn)了,google后找到了如下方法,感興趣的小伙伴們可以參考一下2015-09-09
jQuery post數(shù)據(jù)至ashx實(shí)例詳解
這篇文章主要介紹了jQuery post數(shù)據(jù)至ashx實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下2016-11-11

