首页javascriptspanJavascript Element - 如何改变“span”的内容

Javascript Element - 如何改变“span”的内容

我们想知道如何改变“span”的内容。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){
    var ele = document.querySelector(".classid");
    ele.innerHTML = ele.innerHTML.trim();
    ele.innerHTML = ele.innerHTML.slice(0, -3);
}
</script>
</head>
<body>
  <div id="divid">
    <span class="classid"> CHANGE IT </span>
  </div>
</body>
</html>