初識JQuery 實例一(first)
更新時間: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>
相關(guān)文章
淺談jQuery中ajaxPrefilter的應(yīng)用
下面小編就為大家?guī)硪黄獪\談jQuery中ajaxPrefilter的應(yīng)用。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-08-08
jQuery基于隨機數(shù)解決中午吃什么去哪吃問題示例
這篇文章主要介紹了jQuery基于隨機數(shù)解決中午吃什么去哪吃問題,涉及jQuery基于事件響應(yīng)及隨機數(shù)動態(tài)操作頁面元素相關(guān)實現(xiàn)技巧,需要的朋友可以參考下2018-12-12
jQuery獲取checkboxlist的value值的方法
最近著手一個項目用到了服務(wù)器空間checkboxlist ,使用起來是方便,可以想要從js獲取值就稍微麻煩點了,google后找到了如下方法,感興趣的小伙伴們可以參考一下2015-09-09
jQuery post數(shù)據(jù)至ashx實例詳解
這篇文章主要介紹了jQuery post數(shù)據(jù)至ashx實例詳解的相關(guān)資料,需要的朋友可以參考下2016-11-11

