第一個事件是:當點擊按鈕,會彈出彈框【alert();】事件!javascript
代碼區:html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input tupe="text" id="inp-text">
<select id="select1">
<option>北京</option>
<option>上海</option>
<option>蕪湖</option>
</select>
<input type="button" value="按鈕" id="inp-but">
<script type="text/javascript">
window.onload=function(){
var input=document.getElementById('inp-text');
var select=document.getElementById('select1');
var button=document.getElementById('inp-but');
button.onclick=function(){
alert(input.value);
alert(input.value+"在"+select.value);
}
}
</script>
</body>
</html>java
效果圖:spa
第二種事件是:當點擊按鈕時,則選中select中的,那麼輸入框裏的就對應於select中選中的!htm
第三種事件是:當點擊按鈕,輸入框會對應標籤中的代碼!blog