您好,登錄后才能下訂單哦!
事件onmouseover
<!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> <title>JavaScript星級(jí)評(píng)分</title> <style type="text/css"> *{margin:0;padding:0;} .wrapper{height:20px;padding:5px;width:130px;margin:100px auto 10px;} </style> <script type="text/javascript"> function ArrayIndexOf(arr, element) { for (var i = 0; i < arr.length; i++) { if (arr[i] == element) { return i; } } return -1; } function GetTds() { var tbl = document.getElementById("tblMain"); var tds = tbl.getElementsByTagName("td"); return tds; } function InitEvent() { var tds=GetTds(); for (var i = 0; i < tds.length; i++) { var td = tds[i]; td.onmouseover = TdOnclick; td.style.cursor = "pointer"; } } function TdOnclick() { var tds = GetTds(); var index = ArrayIndexOf(tds, this); for (var i = 0; i <=index; i++) { var td = tds[i]; td.innerHTML = "★"; } for (var j = index + 1; j < tds.length; j++) { var td = tds[j]; td.innerHTML = "☆"; } } </script> </head> <body onload="InitEvent()" class="wrapper"> <table id="tblMain"> <tr><td>☆</td><td>☆</td><td>☆</td><td>☆</td><td>☆</td></tr> </table> </body> </html>
以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時(shí)也希望多多支持億速云!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。