您的位置:首页 > Web前端

Ferris这个教程学习笔记:js示例2.2:函数接收参数并弹出

2013-12-11 16:04 736 查看
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>函数接收参数并弹出</title>
<style type="text/css">
body{font:12px/1.5 Tahoma;text-align:center;}
code,input,button{font-family:inherit;}
input{border:1px solid #ccc;padding:3px;}
button{cursor:pointer;}
</style>
</head>
<body>
<p><input value="北京市" type="text"></p>
<p><input value="朝阳区" type="text"></p>
<p><button>传参</button></p>
<script type="text/javascript">
function point(i1,i2){
alert(i1.value);
alert(i2.value);
}

window.onload = function(){
var button = document.getElementsByTagName("button")[0];
var input = document.getElementsByTagName("input");
button.onclick = function(){
point(input[0],input[1]);
};
};
</script>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: