<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="../../../../jquery-3.6.0.js"></script> <style> *{ margin: 0; padding: 0; } li{ list-style: none; float:left; } </style> </head><body> <div> <span>☆</span> <span>☆</span> <span>☆</span> <span>☆</span> <span>☆</span> </div> <script> $(function () { $("span").on({ "mouseover":function () { var index = $(this).index(); $("span:lt("+(index+1)+")").text("★"); console.log(index+1) }, "mouseout":function () { var index = $(this).index(); $("span:lt("+(index+1)+")").text("☆"); },"click":function () { var index = $(this).index(); $("span:lt("+(index+1)+")").text("★"); $("span").off(); } }) }) </script> </body> </html>
五星好评 jQuery
最新推荐文章于 2024-06-07 23:26:45 发布