为了账号安全,请及时绑定邮箱和手机立即绑定

.value 和 .nodeValue 的区别

.value 和 .nodeValue 的区别

胡说叔叔 2023-03-18 11:05:35
我添加了在此表单上启用自动完成功能所需的 JavaScript 代码。<form>    <label for='shippingName'>Name</label>    <input type='text' id='shippingName' name='shippingName' required></br></br>          </form><form>    <input type='checkbox' id='same' name='same' onchange='billingFunction()'>    <label for='same'>Is the Billing Information the Same?</label>      <label for='billingName'>Name</label>    <input type='text' id='billingName' name='billingName'></br></br>        <input type='submit' value='Verify'></form>我的脚本:function billingFunction(){    if(document.getElementById('same').checked) {        var name = document.getElementById('shippingName').value;             document.getElementById('billingName').value = name;            }else{        document.getElementById('billingName').value = "";            }}我的问题是,如果我在 var 名称中使用 .nodeValue 而不是 .value,该函数将不起作用。它们之间有什么区别?
查看完整描述

1 回答

?
Helenr

TA贡献1780条经验 获得超3个赞

.nodeValue不应该用于获取输入的值,它旨在获取文本节点的数据和数据部分等内容。



查看完整回答
反对 回复 2023-03-18
  • 1 回答
  • 0 关注
  • 55 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信