Blogger Information
Blog 87
fans 0
comment 0
visits 59266
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
第十三节课:1.jQuyerr的工作原理
黄忠倚的博客
Original
602 people have browsed it

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>1.jQuyerr的工作原理</title>
		<style type="text/css">
		ul {
			margin: 30px;
			padding:10px;
			overflow: hidden;
		}
		li {
			list-style-type: none;
			width: 40px;
			height: 40px;
			margin-left: 10px;
			background-color: lightskyblue;
			text-align: center;
			line-height: 40px;
			font-size: 1.2em;
			font-weight: bolder;
			float: left;
			border-radius: 50px;
			box-shadow: 2px 2px 2px #808080;
		}
		/*将对一个小球背景色换成绿色*/
		/*li:first-child {
			background-color: lightgreen;
		}
		li:nth-child(4) {
			background-color: orangered;
			color: white;
		}*/
		/*li:nth-child(4) ~ * {
			background-color: lightgreen;
		}*/
		</style>
</head>
<body>
	<ul>
		<li>1</li>
		<li>2</li>
		<li>3</li>
		<li>4</li>
		<li>5</li>
		<li>6</li>
		<li>7</li>
		<li>8</li>
		<li>9</li>
		<li>10</li>
	</ul>
</body>
</html>
<script type="text/javascript">
	// document.getElementsByTagName('li')[0]
	// li.style.backgroundColor = 'lightgreen'
	 
	// querySelector()
	// 只会返回满足条件的一个元素,但仅返回第一个
	// var li = document.querySelector('li:first-child')
	// li.style.backgroundColor = 'lightgreen'
	
	// var li = document.querySelector('li:nth-child')
	// li.style.backgroundColor = 'orangered' 
	// li.style.color = 'white'
	
	// var li = document.querySelector('li:nth-child(4) ~ *')
	// li.style.backgroundColor = 'lightgreen'
	
	//querySelectorAll ()
	// var li = document.querySelectorAll('li:nth-child(4) ~ *')
	// alert(li.length)
	// for (var i=0;i<li.length;i++){
	// 	li[i].style.backgroundColor = 'lightgreen'
	// }
	
</script>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>

<script type="text/javascript">
		$('li:nth-child(4)~*').css('background-color','lightgreen')
</script>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post