此方法选取jquery对象中的最后一个对象,与:first相对
实例:
<!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-1.12.1.min.js‘></script> <script type=‘text/javascript‘> $(function(){ var lastSelector = $(‘#list li:last‘).get(0).className; alert(lastSelector); }); </script> </head> <body> <ul id=‘list‘> <li></li> <li class=‘eq-selector‘></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li class=‘last-selector‘></li> </ul> </body> </html>
时间: 2024-12-18 11:50:52