1.input和texte
<input type="text"/>
<textarea name="" id="" cols="30" rows="10"></textarea>
获取输入框的值 oninput事件用户输入时触发 onchange输入框失去焦点时触发
window.onload = function() {
var oInput = document.querySelector('input');
oInput.onchange = function(e) {
console.log(this.value)
console.log(e.target.value)
}
oInput.oninput= function(e) {
console.log(this.value)
console.log(e.target.value)
}
}
2.select元素绑定的为value值 selcted为默认选中的值
<select>
<option value ="volvo" selected >Volvo</option>
<option value ="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
3 checkbox
<input type="checkbox" onclick="console.log(this.checked)" >
oInput.addEventListener('change',function(e) {
var e = e || event;
console.log(e.target.checked)
console.log(this.checked)
})