.value和.nodeValue之间的差异



我添加了在该表单上启用自动完成所需的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,则该函数不起作用。他们之间有什么区别?

.nodeValue不应该用于获取输入的值,而是用于获取文本节点和数据节等内容的数据。

最新更新