jQuery基本过滤选择器使用介绍_Javascript教程-查字典教程网
jQuery基本过滤选择器使用介绍
jQuery基本过滤选择器使用介绍
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:使用jQuery基本过滤选择器body{font-size:12px;text-align:center;}div{wid...

复制代码 代码如下:

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<>

<title>使用jQuery基本过滤选择器</title>

<>

<script src="jquery-1.9.1.js" type="text/javascript"></script>

<style type="text/css">

body{font-size:12px;text-align:center;}

div{width:240px;height:83px;border:solid 1px #eee}

he{font-size:13px;}

ul{list-style-type:none;padding:0px}

.DefClass,.NotClass{height:23px;width:60px;line-height:23px;float:left;border-top:solid 1px #eee;border-bottom:solid 1px #eee}

.GetFocus{width:58px;border:solid 1px #666;background-color:#eee}

#spnMove{width:234px;height:23px;line-height:23px;}

</style>

<script type="text/javascript">

$(function () { //增加第一个元素的类别

$('li:first').addClass('GetFocus');

})

$(function () { //增加最后一个元素的类别

$('li:last').addClass('GetFocus');

})

$(function () { //增加去除所有与给定选择器匹配的元素类别

$('li:not(.NotClass)').addClass('GetFocus');

})

$(function () { //增加所有索引值为偶数的元素类别,从0开始计数

$('li:even').addClass('GetFocus');

})

$(function () { //增加所有索引值为奇数的元素类别,从0开始计数

$('li:odd').addClass('GetFocus');

})

$(function () { //增加一个给定索引值的元素类别,从0开始计数

$('li:eq(1)').addClass('GetFocus');

})

$(function () { //增加所有大于给定索引值的元素类别,从0开始计数

$('li:gt(1)').addClass('GetFocus');

})

$(function () { //增加所有小于给定索引值的元素类别,从0开始计数

$('li:lt(4)').addClass('GetFocus');

})

$(function () { //增加标题类元素类别

$('div h1').css('width', '238');

$(':header').addClass('GetFocus');

})

$(function () {

animateIt(); //增加动画效果元素类别

$('#spnMove:animated').addClass('GetFocus');

})

function animateIt() { //动画效果

$('#spnMove').slideToggle('slow', animateIt);

}

</script>

</head>

<body>

<div>

<h1>基本过滤选择器</h1>

<ul>

<li>Item 0</li>

<li>Item 1</li>

<li>Item 2</li>

<li>Item 3</li>

</ul>

<span id="spnMove">Span Move</span>

</div>

</body>

</html>

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Javascript教程学习
    热门Javascript教程学习
    编程开发子分类