2017-04-26 158 views
-1

功能不工作,但它在Chrome和Internet Explorer和Micrisoft邊緣,請大家幫忙功能不工作,但工作在火狐瀏覽器

function myFunctionN() 
{ 
    var filter = event.target.value.toUpperCase(); 
    var rows = document.querySelector("#tablenew").rows; 

    for (var i = 1; i < rows.length; i++) { 
     var firstCol = rows[i].cells[0].textContent.toUpperCase(); 
     var secondCol = rows[i].cells[1].textContent.toUpperCase(); 
     var thirdCol = rows[i].cells[2].textContent.toUpperCase(); 
     var fourtCol = rows[i].cells[3].textContent.toUpperCase(); 
     var fiftCol = rows[i].cells[4].textContent.toUpperCase(); 

     if (firstCol.indexOf(filter) > -1 
     || secondCol.indexOf(filter) > -1 
     || thirdCol.indexOf(filter) > -1 
     || fourtCol.indexOf(filter) > -1 
     || fiftCol.indexOf(filter) > -1 
     ) 
     { 
      rows[i].style.display = ""; 
     } else { 
      rows[i].style.display = "none"; 
     }  
    } 
} 

HTML/PHP代碼,就在這裏沒有數據COS其DB回聲則fetch_data被取爲表

<input type="text" id="myInput" onkeyup="myFunctionN()" placeholder="Search For Anything.." title="Type, What Ever You Looking For"> 
      <div class="table-responsive"> 
       <table id="tablenew" class="table table-bordered"> 
         <tr> 
          <th width="5%">ID</th> 
          <th width="30%">Name</th> 
          <th width="10%">Gender</th> 
          <th width="45%">Designation</th> 
          <th width="10%">Age</th> 
         </tr> 
       <?php 
       echo fetch_data(); 
       ?> 
       </table> 
       <br /> 

      </div> 

error picture

+0

您正在使用哪種版本的Firefox,Chrome和Edge? –

+0

控制檯中的錯誤是什麼?這裏的'事件'是什麼? –

+0

看來你正在使用'event'而沒有定義它。將它用作這樣的參數:'function myFunctionN(event){'...'}'。 – Xufox

回答

0

@Xufox - 你的態度是非常糟糕的兄弟,但你在正確的軌道與T ON帽子事件......我不是程序員,所以你說的方式對我來說沒有任何意義,但是在嘗試了五百種不同的組合之後:)終於搞定了,所以@Xufox ......基本上在腳本函數中添加了事件myFunction04(事件)和事件在html onkeyup =「myFunction04(event)」...問題解決了。謝謝

相關問題