關鍵詞(keyword): onClick 、this

程式:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>59 - JavaScript 基本類 使用onClick、this綜合綀習應用之1</title>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<style type="text/css">
.mybuttonClass{
font-size:20px;
background-color:#ff2277;
}
.test{
font-size:30px;
font-style:inherit;
background-color:#778877;
}
</style>
<script type="text/javascript">
function myMsg(myObj){
alert("onclick 為: " + myObj.onclick);
myMsg2(myObj);
}

function myMsg2(myObj){
myObj.className="test";
alert("className 為: " + myObj.className);
}
</script>
</head>
<body>
<input type="button" id="myButtonId" name="mybuttonName" class="mybuttonClass" value="送出" onclick="myMsg(this)">
</body>
</html>
結果:
第一次按下 送出

 第二次按下 送出

 




 






 















其它文章

arrow
arrow

    PG Levin Li 發表在 痞客邦 留言(0) 人氣()