Javascript,Html,html中按钮点击绑定js事件简单示例
html中按钮点击绑定js事件简单示例
页面完整代码如下:
<!doctype html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>按钮点击绑定js事件简单示例</title>
</head>
<body>
<button onclick="alert('hello c1')">click1</button>
<button onclick="btnC2()">click2 </button>
<button onclick="btnC3('C3')">click3 </button>
<script>
function btnC2(){
alert('hello c2');
}
function btnC3(name){
alert('hello '+name);
}
</script>
</body>
</html>
【版權聲明】
本文爲原創,遵循CC 4.0 BY-SA版權協議!轉載時請附上原文鏈接及本聲明。
原文鏈接:https://tdlib.com/am.php?t=5lv7lbisjvay Tag: Javascript Html