首页javascriptgetJavascript DOM - 如何获取dom元素的当前html

Javascript DOM - 如何获取dom元素的当前html

我们想知道如何获取dom元素的当前html。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
function show(){
   console.log(document.getElementById("abc").innerHTML);
}
window.onload=function(){
    document.getElementById("xyz").setAttribute('value','5');

    show();
}

</script>
</head>
<body>
  <div id=abc>
    <input id=xyz type=text value="2" />
  </div>
  <input type=button value="2" onclick="show()" />
</body>
</html>