dd();function dd() { var s = document.getElementsByClassName("pingStar")[0], m = document.getElementsByClassName('dir')[0], n = s.getElementsByTagName("li"), input = document.getElementsByClassName('startP')[0]; //保存所選值 clearAll = function () { for (var i = 0; i < n.length; i++) { n[i].className = ''; } } for (var i = 0; i < n.length; i++) { n[i].onclick = function () { var q = this.getAttribute("rel"); clearAll(); input.value = q; for (var i = 0; i < q; i++) { n[i].className = 'on'; } m.innerHTML = this.getAttribute("title"); } n[i].onmouseover = function () { var q = this.getAttribute("rel"); clearAll(); for (var i = 0; i < q; i++) { n[i].className = 'on'; } } n[i].onmouseout = function () { clearAll(); for (var i = 0; i < input.value; i++) { n[i].className = 'on'; } } }}在同一個頁面內(nèi),怎么只用這一遍代碼同時實現(xiàn)好幾個這樣的效果
同一個頁面內(nèi)js效果多次使用?
蝴蝶刀刀
2019-03-21 22:19:12