(function(a){
alert("战士连续作战"+parseInt(a/24)+"天"+a%24+"小时");
}(89));
(function(a){
alert("华氏温度("+a+"度)"+" " +"摄氏度"+"("+tmp_trasform(a)+")");
}(80));
function tmp_trasform(tmp){
return parseInt(5/9.0*(tmp-32)*1000)/1000;
}
(function(a){
var total=a;
for(i=1;i<=50;i++)
total+=total*0.05;
alert(total);
}(10));
(function(a){
alert(a%400==0||(a%100!=0&&a%4==0)?"闰年":"不是闰年")
}(2017));
(function(a){
alert(core_(parseInt(a/10)))
}(100));
function core_(core){
switch(core){
case 10:
case 9: return 'A';
case 8: return 'B';
case 7: return 'C';
case 6: return 'D';
}
}
根据输入的数字,返回星期几(function(a){
alert(month_(a))
}(10));
function month_(month){
switch(month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: return 31;
case 2:
if(year%400==0||(year%100!=0&&year%4==0))
return 29;
else
return 28;
default:return 30;
}
}
(function(a){
alert( a+"的值 : "+(a>0?"大于零":a==0?"等于零":"小于零"));
}(-100));
(function(a){
alert( a+"的值 : "+(a%2?"是奇数":"是偶数"));
}(1001));
(function(height,weight){
var tmp=(height-108)*2
alert(tmp+10>=weight?"体重合格":tmp-10<=weight?"体重合格":"体重不合格");
}(180,120));
var x =2;
switch(x){
default:break;
case 1: console.log(1);
case 2: console.log(2);
case 3: console.log(3);
}
var date_="20140211";
var year=parseInt(Number(date_)/10000);
var month=parseInt(Number(date_)/100)%100;
var day=Number(date_)%100;
var total=0;
for(var i=month-1;i>0;i--)
total+=month_(i);
console.log(total+=day);
function month_(month){
switch(month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: return 31;
case 2:
if(year%400==0||(year%100!=0&&year%4==0))
return 29;
else
return 28;
default:return 30;
}
}
<style type="text/css">
*{padding: 0; margin: 0;}
html,body{
width: 100%; height: 100%;
background: #9CBC2C;
font-family: "微软雅黑";
}
ul,ol,input { list-style: none; border: none;}
.main{ width:500px; margin: 50px auto; }
.main .step{
padding-left: 43px;
color: #384313; font-size: 16px; font-weight: bold;
text-shadow: 0 1px 1px #c0d576; line-height: 40px;
}
.main ul li {
width: 400px; height: 25px;
padding-left: 10px;padding-top: 5px; padding-bottom: 5px;
background: rgba(255, 255, 255, .3);
margin: auto; border: solid 2px #e3ebc3;
border-color: rgba(255, 255, 255, .6);
border-radius: 5px; margin-bottom: 4px;
}
.main ul li label{
font-size: 13px; width: 110px; color: #111111;
padding-left: 5px;
}
.main ul li input{
border-radius: 3px;
border: #FC3 solid 1px;
width: 250px; height: 25px; outline: none;
padding-left: 5px; margin-left: 35px;
}
.main .savebtn{
display: block; width: 140px; height: 40px; line-height: 40px;
text-align: center; color: #E3EBC3;
font-weight: bold; cursor: pointer;
border-radius: 5px; margin: 10px auto;
box-shadow: 1px 1px 1px 0px gray;
background: linear-gradient(#50B9FD,#1158A8);
}
style>
<body>
<div class="main">
<span class="step">Step1:用户详细资料span>
<ul>
<li>
<label>用户名称:label>
<input type="text" placeholder="请输入用户名" />
li>
<li>
<label>邮件地址:label>
<input type="text" placeholder="[email protected]" />
li>
<li>
<label>练习电话:label>
<input type="text" placeholder="13539008452" />
li>
ul>
<span class="step">Step2:家庭住址(收货地址)span>
<ul>
<li>
<label>详细地址:label>
<input type="text" placeholder="请输入用户名" />
li>
<li>
<label>邮政编码:label>
<input type="text" placeholder="[email protected]" />
li>
<li>
<label>国 家:label>
<input type="text" placeholder="13539008452" />
li>
ul>
<span class="savebtn">保存span>
div>
body>
|