总结:
通过学习jquery对象中,不仅可以用css,style控制样式还可以用script对象实现。在script中,toArray()可以返回dom值;find()返回所以后代元素;eq()返回指定的对象而且是从0开始的,children()返回所以得直接的子元素。。each(function)){})回调.....
实例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <!--<form action="" method="pot"> <fieldset> <legend>用户注册表</legend> <p>用户名:<input type="text" name="name" required=""></p> <p>邮箱:<input type="email" name="email" required=""></p> <p>密码:<input type="password" name="psw1" required=""></p> <p>确认密码:<input type="password" name="paw2" required=""></p> <p>性别: <input type="radio" name="gender" value="male">男 <input type="radio" name="gender" value="female">女 </p> <p>上传图片:<input type="file" name=""></p> <p>wed语言: <input type="checkbox" name="lang[]" value="js">js <input type="checkbox" name="lang[]" value="php">php <input type="checkbox" name="lang[]" value="html">html <input type="checkbox" name="lang[]" value="css">css </p> <p>级别: <select name="level"> <option value="0">小白</option> <option value="1">入门</option> <option value="2">中级</option> <option value="3">高级</option> </select> </p> <p><textarea cols="40" rows="5"></textarea></p> <p> <button type="submit" name="submit">提交</button> <button type="reset" name="reset">重置</button> </p> </fieldset> </form>--> <ul> <li>桥 最懂水的柔情。<a href="">下载</a></li> <li>你相信时光不老吗。<a href="">下载</a></li> <li>那缠绵了千年的细吻。<a href="">下载</a></li> <li>依然保持着最深情的姿势。<a href="">下载</a></li> </ul> </body> </html> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script type="text/javascript"> //$(':input').css('color','red') //$(':input:password').css('background-color','blue') $('li').eq(1).text().css('color','red') $('ul').file('li').css('color','blue') $('li').first().css('color','#363636') $('ul').children(p).css('color','green') $('li').last().css('color','red') $('ul').find('li').css('color','blue') </script>
运行实例 »
点击 "运行实例" 按钮查看在线实例