abstract:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <title>JQ选择器</title> <style> *{ padding: 0; margin: 0; font-size: 14px; } .box{ width: 1200px; height: auto; margin: 30px auto; } p.title{ font-weight: bold; text-align: center; font-size: 20px; padding:20px 0; } .div1{ width: 30px; height: 30px; background: #f00; } .xz{ width: 100%; height: 40px; } </style> </head> <body> <div class="box"> <p class="title">JQ选择器</p> <div class="xz"> <input type="submit" value="div变色 " id="bs" > <input type="submit" value="li奇数变色 " id="li1" > <input type="submit" value="li偶数变色" id="li2" > <input type="submit" value="li大于4变色" id="li3" > <input type="submit" value="li小于4变色" id="li4" > <input type="submit" value="li第一个元素变色" id="li5" > <input type="submit" value="li最后一个元素变色" id="li6" > <input type="submit" value="[type]元素变色" id="li7" > <input type="submit" value="w开头元素变色" id="li8" > <input type="submit" value="移除被选中的元素" id="li9" > </div> <div class="div1"></div> <ul> <li>我是列表</li> <li>我是列表</li> <li>我是列表</li> <li>我是列表</li> <li>我是列表</li> <li>我是列表</li> <li>我是列表</li> <li>我是列表</li> <li>我是列表</li> <li>我是列表</li> <li>我是列表</li> <li>我是列表</li> </ul> <form action=""> <input type="text" value="wwwaaaccc"> <input type="text" value="1wwwaaaccc"> <label><input type="checkbox" name="">看书</label> <label><input type="checkbox" name="" checked>游泳</label> <label><input type="checkbox" name="">游戏</label> </form> </div> <script> $(function(){ $('#bs').click(function(){ $('.div1').css('background','blue'); }); $('#li1').click(function(){ $('li:odd').css('color','#ff6700'); }); $('#li2').click(function(){ $('li:even').css('color','#ff6700'); }); $('#li3').click(function(){ $('li:gt(4)').css('color','#ff6700'); }); $('#li4').click(function(){ $('li:lt(4)').css('color','#ff6700'); }); $('#li5').click(function(){ $('li:first').css('color','#ff6700'); }); $('#li6').click(function(){ $('li:last').css('color','#ff6700'); }); $('#li7').click(function(){ $('input[type]').css('color','#ff6700'); });$('#li8').click(function(){ $('input[value ^=w]').css('color','#ff6700'); }); $('#li9').click(function(){ $(':checked').parent().remove(); }); }) </script> </body> </html>
Correcting teacher:查无此人Correction time:2019-04-30 09:18:35
Teacher's summary:完成的不错。jq比js简单很多,常用可以代替js常规操作。继续加油。