1. 程式人生 > >獲取option標籤的值和value屬性值

獲取option標籤的值和value屬性值

<!DOCTYPE html>
<html>
<body>
	<select onchange="_sel(this.options[this.options.selectedIndex])">
		<option value="volvo">Volvo</option> 
		<option value="saab">Saab</option> 
		<option value="opel">Opel</option>
		<option value="audi">Audi</option> 
	</select>
	<script>
		function _sel(val){
			alert(val.innerHTML);
			alert(val.value)
		}
	</script>
</body>
</html>