我遇到此错误Uncaught TypeError:无法在checkatrivalues.js:10上将属性'innerHTML'设置为null

时间:2020-03-14 19:24:58

标签: javascript

var firstItem = document.getElementById("one"); //get first list item

if (firstItem.hasAttribute("class")) {
  //if it has a class attribute

  var attr = firstItem.getAttribute("class"); //get the attribute

  var el = document.getElementById("scriptResults"); //add the value of the attribute after the list

  el.innerHTML = "<p>the first item has a class name: " + attr + "</p>";
}

0 个答案:

没有答案
相关问题