根据给定的id匹配一个元素

 选择器               描述                             返回                  示例  
  
 #id                 根据给定的id匹配一个元素          单个元素             $("#test")选取id为test的元素 
 
 
node2:/var/www/html/jquery#cat t17.html 
<li id='aaa'>1111111111</id>
<li id='test'>222222222</id>
<li id='ccc'>3333333333</id>
<li id='ddd'>44444444444</id>
<script type="text/javascript" src="jquery-2.2.2.min.js"></script>
<script type="text/javascript" src="t17.js"></script>
node2:/var/www/html/jquery#

node2:/var/www/html/jquery#cat t17.js
$('#test').css("background","red");

猜你喜欢

转载自blog.csdn.net/zhaoyangjian724/article/details/88530822