初识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获取checkboxlist的value值的方法
最近着手一个项目用到了服务器空间checkboxlist ,使用起来是方便,可以想要从js获取值就稍微麻烦点了,google后找到了如下方法,感兴趣的小伙伴们可以参考一下2015-09-09


最新评论