亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

求問代碼 一直反復出現81行內容錯誤 但是已經定義為value值

求問代碼 一直反復出現81行內容錯誤 但是已經定義為value值

<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <style> <!--默認顯示格式--> .into { background-color: #98FB98; color: #858687; } .inchange { background-color: #9ACD32; color: #000000; } <!--選中顯示格式--> </style> </head> <body> <div> <div><input type="text" id="div_tex" /></div> <div id="result"></div> </div> </body></html><script> var arr = ['java', 'js', 'jq', 'SQL', 'MySQL']; var temp = []; //將 獲取ID函數抽取出來 function $(id) { return document.getElementById(id); } // ? var div_texx = $('div_tex').value; //取文本框內容后 判斷它是否數據庫含有元素 如果是創建臨時數組賦值 ?如果不為空執行遍歷函數 function handler() { var div_tex = $('div_tex'); var div_texx = div_tex.value; if(div_tex.value != null && div_tex.value != "" && div_tex.value.length > 0) { create_temp(div_tex.value); if(temp != null && temp.length > 0) { show(tem); } else { cleanContent(); } } else { cleanContent(); } } //清空函數 function cleanContent() { var none = $('result'); if(none.firstChild != null) { none.removeChild(none.firstChild); cleanContent(); } } //創建臨時數組 function create_temp(div_texx) { temp.length = 0; for(var i = 0; i <= arr.length; i++) { if(arr[i].indexOf(div_texx) != -1) { temp.push(arr[i]); } } } //智能索引菜單 show function show() { var result = $('result'); cleanContent(relut); for(var i = 0; i <= temp.length; i++) { var div = document.createElement("div"); div.innerHTML = temp[i]; div.className = "into"; //鼠標移動 div.onmousemove = function() { this.className = "inchange" } //鼠標選中 div.onmouseout = function() { this.className = "into" } //點擊回車 div.onclick = function() { div_texx = this.innerHTML; cleanContent(); } result.appendChild(div); } } //鍵盤監控判斷 window.onkeyup = function(event) { var result = $('result'); if(event.keyCode == "38") { var curr = document.getElementByClassName('inchange')[0]; if(curr == null) { result.lastChild.className = 'inchange'; return; } else if(curr.previousSibling != null) { curr.previousSibling.className = 'inchange'; curr.className = 'into'; } else { return; } } else if(event.keyCode == "40") { var curr = document.getElementByClassName('inchange')[0]; if(curr == null) { result.firstChild.className = 'inchange'; return; } else if(curr.nextSibling != null) { curr.nextSibling.className = 'inchange'; curr.className = 'into'; } else { return; } } else if(event.keyCode == "13") { var curr = document.getElementByClassName('inchange')[0]; $('div_tex').value = curr.innerHTML; cleanContent(); } else { handler(); } }</script>
查看完整描述

1 回答

?
chwech

TA貢獻63條經驗 獲得超18個贊

arr[i].indexOf(div_texx) != -1這里不知是第幾行,indexOf不是由數組調用嗎?arr[i]不是數組元素嗎?

查看完整回答
反對 回復 2016-08-13
  • 1 回答
  • 0 關注
  • 1770 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號