学生教材网 >程序设计 > 代码分享 > JavaScript > 浏览文章

javascript 基础

来源:网络编辑:佚名时间:2015-12-23人气:

拐带天才txt,集分宝签到,新乡学院专升本

体重计算器 标签: <无>

代码片段(1) [全屏查看所有代码]

1. [文件] index4.html ~ 2KB     下载(0)     跳至 [1] [全屏预览]

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			*{margin:0;padding: 0;}
			.box{width:500px;height:500px;margin:100px auto;border: 3px solid #abcdef;}
			.box h1{width:500px;height:100px;line-height:100px;text-align: center;}
			.box .txt{width:350px;height:30px;margin-top:20px;}
			.box .txt4{width:300px;height:40px;margin:20px 100px;text-align: center;}
			.box .txt5{width:400px;height:100px;margin-top:10px;}
		</style>
	</head>
	<body>
		<div class="box">
			<h1>体重计算器</h1>
			身高:<input id="txt1" class="txt" type="text" value="" />cm<br/>
			体重:<input id="txt2" class="txt" type="text" value="" />厘米<br />
			<input id="btn" class="txt4" type="button" value="开始计算" /><br />
			结果:<input id="txt3" class="txt5" value />
			
		</div>
		<script type="text/javascript">
			window.onload= function(){
				var oBtn = document.getElementById("btn");
				var oTxt1 = document.getElementById("txt1");
				var oTxt2 = document.getElementById("txt2");
				var oTxt3 = document.getElementById("txt3");
					
				
				oBtn.onclick = function(){
					if(isNaN(parseInt(oTxt1.value)) ||isNaN(parseInt(oTxt2.value))){
						alert("输入错误")
					}else{
						var oWeight = (parseInt(oTxt1.value)-108)*2;
						if( oTxt2.value - oWeight> 10){
							oTxt3.value = "你超重了,胖的和猪似的,该减肥了";
						}else if(oTxt2.value - oWeight < -10){
							oTxt3.value = "你瘦的和猴子一样,得加强营养啊"
							
						}
						else{
							oTxt3.value = "你的体重很标准,继续保持";
						}
					}
					
					
					
					
				}
				
				
				
				
				
				
				
			}
			
			

		</script>
	</body>
</html>

bootstrap-select使用

bootstrap-select没提供动态请求数据的方法,解决动态添加的问题下载,例子,文档地址http://silviomoreto.github.io/bootstrap-select/标签:<无>-->-->-->1.

改造BOOTSTRAP的TAB

最近在做一个前端,需要点击按钮创建一个可关闭的标签页,没有找到合适的,最后想到不如改造一下bootstrap省事。

Tags标签ltgtpxtxtvalue

热门推荐