首页 > 解决方案 > 在 chrome 的控制台中显示 HTMLInputElement

问题描述

我想显示 HTML 输入的 HTMLInputElement 对象:

 <div>
  <input type="text" id="name" name="toto" value="test" />
</div>

JS脚本:

<script>
  const inputEl = document.getElementById("name"); 
  console.log(inputEl);
</script>

在 chrome 控制台中,我得到了这个:

在此处输入图像描述

但我想将它显示为 HTMLInputElement 对象。

在 stackblitz 控制台中,我得到了对象:

在此处输入图像描述

谢谢 :)

但是在本地我没有得到对象!

标签: javascripthtml

解决方案


不是 100% 确定您所说的“显示为 HTMLInputElement”是什么意思。如果您想查看其所有字段,您可能需要使用console.dir(inputEl).


推荐阅读