您的位置:首页 > Web前端 > JQuery

夺命雷公狗jquery---3普通选择器

2015-10-18 22:24 639 查看
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="js/jquery.js"></script>
<script>
window.onload = function(){
document.getElementById('btnok').onclick = function(){
//1.匹配第一个单元格
//$('td:first').html('test');
//2.匹配最后一个单元格
//$('td:last').html('test');
//3.通过odd和even实现隔行变色
//$('td:odd').css('backgroundColor','red');
//4.匹配索引为5的单元格
//$('td:eq(5)').css('backgroundColor','red');
//5匹配索引大于5的所有单元格
//$('td:gt(5)').css('backgroundColor','red');
//6.匹配索引小于5的所有单元格
//$('td:lt(5)').css('backgroundColor','red');
//7.匹配除索引5以外的所有td元素
$('td:not(td:eq(5))').css('backgroundColor','red');
}
}
</script>
</head>
<body>
<input type="button" id="btnok" value="匹配" />
<br/>
<table width="800" border="1">
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: