jQuery find() 及<ul><li>的使用

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.7.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("button").click(function(){
		$("ul.i9").find('li').css('background-color', 'red');
	});
	
});
</script>
</head>
<body>
	<button style="width: 10%" >点击</button>
	<ul class="i0">
		<li class="i1">I</li>
		<li class="i2">II
			<ul class="i3">
				<li class="i4">1</li>
				<li class="i5">2
					<ul class="i6">
						<li class="i7">A</li>
						<li class="i8">B
							<ul class="i9">
								<li class="i10">a</li>
								<li class="i11">b</li>
					    	</ul>
						</li>
						<li class="i12">C</li>
					</ul>
			    </li>
				<li class="i13">3</li>
			</ul>
		</li>	
		<li class="i14">III</li>
	</ul>
</body>
</html>

效果图如下所示:

jQuery find() 及<ul><li>的使用

参考地址:http://www.w3school.com.cn/jquery/traversing_find.asp

相关推荐