Magum Opus

트레인스포팅2

영화2018. 1. 13. 23:17



시간이 만드는 감정은 언제나 좋다.

'영화' 카테고리의 다른 글

윈드리버(2016)  (0) 2017.12.24


'영화 > 영화이야기' 카테고리의 다른 글

영화를 좋아한다면? -유튜브 채널추천  (0) 2016.08.22

<!DOCTYPE html>
<html lang="kr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>날짜계산기</title>
<script>
var today = new Date().getTime();
var soloday = function(){
var birth = document.getElementsByTagName("input")[0].value;
var year = birth.split("-")[0];
var month = birth.split("-")[1];
var day = birth.split("-")[2];

var birthDay = new Date( year, month-1, day).getTime()
var time = today-birthDay
var sDay = Math.ceil(time/(1000*60*60*24));
document.getElementsByClassName("text")[0].innerHTML = "모솔" + "<span>"+sDay+"</span>" + "일차..."
}
</script>
<style>
#box{margin:0 auto;width:300px;height:200px;}
#box input{width:100px;height:30px;font-size:16px;}
#box .text{font-size:18px;}
#box span{font-style:bold;color:#f00}
</style>
</head>
<body>
<div id="box">
<input type="text" value="1996-12-10" /> <button class="btn" onclick="soloday()">입력</button>
<p class="text"></p>
</div>
</body>
</html>


' > javascript' 카테고리의 다른 글

띠 구하기  (0) 2018.01.03
노드를 클릭할때마다 클래스를 토글시키는법  (0) 2017.12.11
2017.11.29  (0) 2017.11.29

띠 구하기

웹/javascript2018. 1. 3. 01:17
<!DOCTYPE html>
<html lang="kr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>띠계산기</title>
<script>
var MySign = function(){
var birth_Y = document.getElementsByTagName("input")[0].value;
var SignArray = ["닭","개","돼지","쥐","소","범","토끼","용","뱀","말","양","원숭이"]
var remainder = birth_Y % 12;
alert.log("당신은 " + SignArray[remainder-1] + "띠 입니다.")
}
</script>
<style>
#box{margin:0 auto;width:300px;height:200px;}
#box input{width:100px;height:30px;font-size:16px;}
#box .text{font-size:18px;}
#box span{font-style:bold;color:#f00}
</style>
</head>
<body>
<div id="box">
<input type="text" value="1996" maxlength="4"/> <button class="btn" onclick="MySign()">입력</button>
<p class="text"></p>
</div>
</body>
</html>




이렇게 했다가 줄엿다...

if (birth_Y%12 == 1){
console.log("당신은 닭띠 입니다.")
}else if(birth_Y%12 == 2){
console.log("당신은 개띠 입니다.")
}else if(birth_Y%12 == 3){
console.log("당신은 돼지띠 입니다.")
}else if(birth_Y%12 == 4){
console.log("당신은 쥐띠 입니다.")
}else if(birth_Y%12 == 5){
console.log("당신은 소띠 입니다.")
}else if(birth_Y%12 == 6){
console.log("당신은 범띠 입니다.")
}else if(birth_Y%12 == 7){
console.log("당신은 토끼띠 입니다.")
}else if(birth_Y%12 == 8){
console.log("당신은 용띠 입니다.")
}else if(birth_Y%12 == 9){
console.log("당신은 뱀띠 입니다.")
}else if(birth_Y%12 == 10){
console.log("당신은 말띠 입니다.")
}else if(birth_Y%12 == 11){
console.log("당신은 양띠 입니다.")
}else if(birth_Y%12 == 0){
console.log("당신은 원숭이띠 입니다.")




최종


<!DOCTYPE html>
<html lang="kr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>띠계산기</title>
<script>
function MySign() {
var birth_Y = document.getElementsByTagName("input")[0].value;
if (birth_Y === "") {
return alert("숫자를 입력해주세요.");
}
var SignArray = [
"원숭이",
"닭",
"개",
"돼지",
"쥐",
"소",
"범",
"토끼",
"용",
"뱀",
"말",
"양"
];
var color = ["하얀", "검은", "파란", "붉은", "황금"];
var twelve = ["신", "유", "술", "해", "자", "축", "인", "묘", "진", "사", "오", "미"];
var stems = ["경", "신", "임", "계", "갑", "을", "병", "정", "무", "기"];
var remainder_a = birth_Y % 12;
var remainder_b = birth_Y % 10;
var colorNum = Math.floor(remainder_b / 2);
alert(
"당신은 " +
stems[remainder_b] +
twelve[remainder_a] +
"년에 태어났습니다." +
"\n" +
color[colorNum] +
SignArray[remainder_a] +
"띠"
);
}
</script>
<style>
#box{margin:0 auto;width:300px;height:200px;}
#box input{width:100px;height:30px;font-size:16px;}
#box .text{font-size:18px;}
#box span{font-style:bold;color:#f00}
</style>
</head>
<body>
<div id="box">
<input type="text" value="" minlength="4" maxlength="4" onkeypress="javascript:if(event.keyCode == 13){MySign()}"/> <button class="btn" onclick="MySign()">입력</button>
<p class="text"></p>
</div>
</body>
</html>


' > javascript' 카테고리의 다른 글

모솔 몇일차인지 구하기....  (0) 2018.01.03
노드를 클릭할때마다 클래스를 토글시키는법  (0) 2017.12.11
2017.11.29  (0) 2017.11.29