获取匹配的第一个元素:
实例:
<!DOCTYPE html> <html lang=‘zh-cn‘> <head> <title>Insert you title</title> <meta http-equiv=‘description‘ content=‘this is my page‘> <meta http-equiv=‘keywords‘ content=‘keyword1,keyword2,keyword3‘> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!-- <script type=‘text/javascript‘ src=‘./js/jquery-3.0.0.js‘></script> --> <script type=‘text/javascript‘ src=‘./js/jquery-1.12.1.min.js‘></script> <style type=‘text/css‘> li{width:100%;height:20px;margin:10px 0;background:GreenYellow;font:400 13px/20px ‘Courier New‘;color:#000;text-align:center;} </style> <script type=‘text/javascript‘> $(function(){ $(‘#list li:first‘).html(‘":first : "伪类选择器演示‘); }); </script> </head> <body> <ul id=‘list‘> <li></li> <li class=‘active‘></li> <li></li> <li></li> </ul> </body> </html>
时间: 2024-10-15 13:05:57