首页 > Web开发 > 详细

js onclick事件(未测试)

时间:2015-03-10 13:44:03      阅读:296      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE html>

<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
var Price = 100                                                                                  
function getprice (){
var Getprice = document.getElementById("price").value;
if(Getprice>Price)        //Price !=100
{
alert("余额不足")
};
else{
("正在出钱,等一辈子吧。")
};
}
function Sprice(){
var SPrice = document.getElementById(“price”).value;
Price=parseInt(SPrice)+Price  //变量转换字符串 parseInt()
alert("你一共存了“+SPrice+",余额为"+Price)
}
</head>
<body>
<input type="text" id="price" value=""/>
<input type="button" value="点我取钱" onclick="getprice()"/>
<input type="button" value="点我存钱" onclick="Sprice"/>
</body>
</html>

js onclick事件(未测试)

原文:http://www.cnblogs.com/xanthechum/p/4325615.html

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