<form >
<input type="text" id="user"> <br/>
男:<input type="radio" name="sex" value="男">
女:<input type="radio" name="sex" value="女" checked> <br/>
rap: <input type="checkbox" name="hobby" id="" value="rap" >
篮球: <input type="checkbox" name="hobby" id="" value="basketball">
跳舞: <input type="checkbox" name="hobby" id="" value="dance"> <br>
<select name="" id="city">
<option value="陕西">陕西</option>
<option value="山西">山西</option>
<option value="河南">河南</option>
<option value="河北">河北</option>
</select>
<br>
<textarea name="" id="text" cols="30" rows="10"></textarea> <br>
<input type="button" value="提交" id="btn">
</form>
var btn= document.getElementById("btn");
btn.onclick=function(){
var user=document.querySelector("#user").value;
console.log("user:",user);
var sexDom=document.getElementsByName("sex");
for(var i=0;i<sexDom.length;i++){
if(sexDom[i].checked == true){
var sex= sexDom[i].value;
}
}
console.log("sex:",sex)
var hobbyDom=document.getElementsByName("hobby");
var hobby=[];
for(var j=0 ;j<hobbyDom.length;j++){
if(hobbyDom[j].checked == true){
hobby.push( hobbyDom[j].value )
}
}
console.log("hobby:",hobby)
var city=document.getElementById("city").value;
console.log("city:",city)
var text=document.getElementById("text").value;
console.log("text:",text)
}