<input id="email" name="email" type="text" value="ooooo@gmail.com">
如何获取id=email的值并将其打印到我的控制台或任何地方进行测试?
我试过了,但没有运气:(
script type="text/javascript">
document.getElementById('email').innerText;
</script>
<input id="email" name="email" type="text" value="ooooo@gmail.com">
如何获取id=email的值并将其打印到我的控制台或任何地方进行测试?
我试过了,但没有运气:(
script type="text/javascript">
document.getElementById('email').innerText;
</script>
9条答案
按热度按时间a6b3iqyw1#
有两种类型的元素
1.块-可以在jquery中使用-
.innerHTML
或.html()
访问这些块,如div的span等1.非块元素-这些元素可以通过jquery中的
.value
或.val()
访问,如输入类型等你要做的就是
hec6srdp2#
尝试
x7rlezfr3#
尝试提醒...
http://jsfiddle.net/nemb666L/
1l5u6lss4#
这将把整个对象“打印”到控制台
ht4b089n5#
不使用jQuery:
jqjz2hbq6#
很管用
vd8tlhqk7#
在Chrome开发工具控制台中删除.value:
ntjbwcob8#
ercv8c1e9#
如果没有定义
email
(您的id),只需: