就是淘宝上类似 |
|
20分 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> </head> <body> <style> #QuacorGrading input { background:transparent url(upload_files/jsimg/grading.png) no-repeat scroll right center; border:0 none; cursor:pointer; height:30px; width:30px; padding:0; vertical-align:middle;}</style> <div id="QuacorGrading" style="position:absolute;top:230px; left:150px"><strong>评分</strong> <input name="1" type="button" /> <input name="2" type="button" value="2"/> <input name="3" type="button" value="3"/> <input name="4" type="button" value="4"/> <input name="5" type="button" value="5"/> <input name="6" type="button" value="6"/> <input name="7" type="button" value="7"/> <input name="8" type="button" value="8"/> <input name="9" type="button" value="9"/> <input name="10" type="button" /> <span id="QuacorGradingValue"><b><font size="5" color="#fd7d28">6.5</font></b>分</span> <script type="text/javascript"> var GradList = document.getElementById("QuacorGrading").getElementsByTagName("input"); for(var di=0;di<parseInt(document.getElementById("QuacorGradingValue").getElementsByTagName("font")[0].innerHTML);di++){GradList[di].style.backgroundPosition = ""left center"";} for(var i=0;i < GradList.length;i++){ GradList[i].onmouseover = function(){ for(var Qi=0;Qi<GradList.length;Qi++){ GradList[Qi].style.backgroundPosition = ""right center""; } for(var Qii=0;Qii<this.name;Qii++){ GradList[Qii].style.backgroundPosition = ""left center""; } //alert(GradList.length); document.getElementById("QuacorGradingValue").innerHTML = ""<b><font size="5" color="#fd7d28">""+this.name+""</font></b>分""; } } </script> </div> </body></html> |
效率 |
|
60分 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <h1>评分:</h1> <table id="rating"> <tr> <td>☆</td> <td>☆</td> <td>☆</td> <td>☆</td> <td>☆</td> </tr> </table> <script type="text/javascript"> var rating=document.getElementById("rating"); var tds=rating.getElementsByTagName("td"); for(var i=0;i<tds.length;i++){ tds[i].onmouseover=function(){ var index=getIndex(tds,this); for(var i=0;i<=index;i++){ tds[i].innerHTML="★"; } } tds[i].onmouseout=function(){ for(var i=0;i<tds.length;i++){ tds[i].innerHTML="☆"; } } tds[i].style.cursor=""pointer""; } function getIndex(hc,element){ for(var i=0;hc.length;i++){ if(hc[i]==element){ return i; } } return -1; } </script> </body> </html> 效果: |