object(mysqli_result)#13 (5) { ["current_field"]=> int(0) ["field_count"]=> int(25) ["lengths"]=> NULL ["num_rows"]=> int(1) ["type"]=> int(0) } 如何在JavaScript中按Class獲取元素? - 程序員論壇 - Powered by Discuz!

程序員論壇

標題: 如何在JavaScript中按Class獲取元素? [打印本頁]

作者: GreenCup    時間: 2020-8-13 21:41
標題: 如何在JavaScript中按Class獲取元素?
如何在JavaScript中按Class獲取元素?
How to Get Element By Class in JavaScript?
  1. function replaceContentInContainer(matchClass, content) {
  2.     var elems = document.getElementsByTagName('*'), i;
  3.     for (i in elems) {
  4.         if((' ' + elems[i].className + ' ').indexOf(' ' + matchClass + ' ')
  5.                 > -1) {
  6.             elems[i].innerHTML = content;
  7.         }
  8.     }
  9. }
複製代碼





歡迎光臨 程序員論壇 (http://program.thesmartfire.com/) Powered by Discuz! X2.5