首页 > 编程语言 > 详细

javascript关于onclick()

时间:2017-10-09 18:29:30      阅读:239      评论:0      收藏:0      [点我收藏+]

1

<html>
<head>
<title>js1
</title>
<style>
#content{
margin:0 auto;
text-align:center;
}
</style>
</head>
<body onload="alert(‘hello!‘);">
<div id=content>
<img src="stone.jpg"/>
</div>
</body>
</html>

 

2

<html>
<head>
<title>js1
</title>
<style>
#content{
margin:0 auto;
text-align:center;
}
#rockImg{
cursor:pointer;}
</style>
<script>
function touchRock(){
var userName=prompt("你的名字是什么?");
if(userName)
{
alert("很高兴遇见你"+userName+"!");
document.getElementById("rockImg").src="rock_stone.jpg";
}}
</script>
</head>
<body>
<div id=content>
<img id="rockImg" src="stone.jpg" onclick="touchRock()"/>
</div>
</body>
</html>

脚本通常以以下几种方式:文本/数字/布尔

区分常量(const)和变量(var)

javascript关于onclick()

原文:http://www.cnblogs.com/Yimi/p/7642143.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!