初識JQuery 實例一(first)
更新時間:2011年03月16日 23:51:02 作者:
用jquery為ul下的li依次設置樣式的代碼,主要是利用了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>
復制代碼 代碼如下:
<!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基于隨機數(shù)解決中午吃什么去哪吃問題示例
這篇文章主要介紹了jQuery基于隨機數(shù)解決中午吃什么去哪吃問題,涉及jQuery基于事件響應及隨機數(shù)動態(tài)操作頁面元素相關實現(xiàn)技巧,需要的朋友可以參考下2018-12-12
jQuery獲取checkboxlist的value值的方法
最近著手一個項目用到了服務器空間checkboxlist ,使用起來是方便,可以想要從js獲取值就稍微麻煩點了,google后找到了如下方法,感興趣的小伙伴們可以參考一下2015-09-09
jQuery post數(shù)據(jù)至ashx實例詳解
這篇文章主要介紹了jQuery post數(shù)據(jù)至ashx實例詳解的相關資料,需要的朋友可以參考下2016-11-11

