일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- 유벤투스
- 맨시티
- export
- HTML
- 간편정리
- 파탄잘리
- 라카제르
- 바르셀로나
- 레스터
- 첼시
- JavaScript
- 베식타스
- 마티치
- HTML 제어
- 오피셜
- Eclipse
- UX/UI
- 아스널
- jsp
- 네이마르
- CSS
- 루카쿠
- 프로젝트
- jQuery
- 이클립스
- UI/UX
- HTML/CSS
- 마동석
- 치차리토
- 맨유
- Today
- Total
Be a groovy man by positive thinking
UI/UX_009 본문
간편정리
예문
Ex_01
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<script>
function f1(){ document.write("aaa");
}
function f2(){
document.write("bbb");
}
f1();
f2();
</script>
</body>
</html>
Ex_02 aaa가 나오게 출력하시오
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
function f1() {
function f2() {
document.write("aaa");
}
}
</script>
</body>
</html>
Sol_02
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
function f1() {
function f2() {
document.write("aaa");
}
f2();
}
f1();
</script>
</body>
</html>
Ex_03
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
var a=function() {
document.write("무명함수");
}
a();
</script>
</body>
</html>
Ex_04
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
a(); //위에서 호출하면 안된다.
var a=function() {
document.write("무명함수");
}
</script>
</body>
</html>
Ex_05 here을 완성하여 무엇이든 나오게 하시오
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
function f1(f2) {
document.write(f2());
}
//here
</script>
</body>
</html>
Sol_05
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
function f1(f2) {
document.write(f2());
}
f1(function() {
return "연습"
});
</script>
</body>
</html>
Ex_06 100 200이 출력될수 있게 하시오
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
var a = 100;
var b = function() {
return 200;
};
function f1(c) {
document.write(c);
}
f1(a);
f1(b);
</script>
</body>
</html>
Sol_06
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
var a = 100;
var b = function() {
return 200;
};
function f1(c) {
if((typeof c)!=function){
document.write(c);
}else{
document.write(c());
}
}
f1(a);
f1(b);
</script>
</body>
</html>
Ex_07 실행해보시오
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
var a = 100;
var b = function() {
return 200;
};
var c = "abc";
var d = true;
var e = {
"aa" : "bb",
"cc" : "dd"
};
var f = new Date();
document.write(typeof a);
document.write("<br/>");
document.write(typeof b);
document.write("<br/>");
document.write(typeof c);
document.write("<br/>");
document.write(typeof d);
document.write("<br/>");
document.write(typeof e);
document.write("<br/>");
document.write(typeof f);
document.write("<br/>");
document.write(typeof g);
</script>
</body>
</html>
Ex_08
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
function f1() {
return function() {
return 100;
};
}
//here
</script>
</body>
</html>
Sol_08
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
function f1() {
return function() {
return 100;
};
}
var a=f1();
document.write(a());
</script>
</body>
</html>
Ex_09
100
200 300
400 500 600 가 나오게 소스코드를 작성하시오
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
function f() {
document.write(arguments[0]);
}
f(100);
f(200, 300);
f(400, 500, 600);
</script>
</body>
</html>
Sol_09
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
function f() {
for (var a = 0; a < arguments.length; a++) {
document.write(arguments[a]+" ");
// 는 한칸 띄우는 것임
}
document.write("<br>");
}
f(100);
f(200, 300);
f(400, 500, 600);
</script>
</body>
</html>
Ex_10
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
//here
document.write(max(5, 7) + "<br>");
document.write(max(3, 1) + "<br>");
</script>
</body>
</html>
Sol_10
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
function max(s, t) {
if (s > t) {
return s;
} else {
return t;
}
}
document.write(max(5, 7)+"<br>");
document.write(max(3, 1)+"<br>");
</script>
</body>
</html>
Ex_11 here을 완성하여 7단과 5단을 출력하시오
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
//here
printGugudan(7);
document.write("<hr>");
printGugudan(5);
document.write("<hr>");
</script>
</body>
</html>
Sol_11
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script>
function printGugudan(s){
document.write(": : "+s+" 단 : :"+"<br>");
for(var t=1; t<10; t++){
document.write(s +" * "+t+" = "+s*t+"<br>");
}
}
printGugudan(7);
document.write("<hr>");
printGugudan(5);
document.write("<hr>");
</script>
</body>
</html>
Ex_12 here을 완성하여 table을 완성하시오
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
td {
border: 2px solid navy;
}
</style>
</head>
<body>
<script>
//here
createTable(3, 5);
</script>
</body>
</html>
Sol_12_1
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
td {
border: 2px solid navy;
}
</style>
</head>
<body>
<script>
function createTable(row, column) {
var num = 1;
var htmlStr = "<table>";
for (var a = 0; a < row; a++) {
htmlStr += "<tr>";
for (var b = 0; b < column; b++) {
htmlStr += "<td>";
htmlStr += num++;
htmlStr += "</td>";
}
htmlStr += "</tr>";
}
htmlStr += "</table>";
document.write(htmlStr);
}
createTable(3, 5); // 3줄5칸
</script>
</body>
</html>
Sol_12_2
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
td {
border: 2px solid navy;
}
</style>
</head>
<body id="bodyTag">
<script>
function createTable(s, t) {
var tableTag = document.createElement("table");
bodyTag.appendChild(tableTag);
for (a = 0, n = 1; a < s; a++) {
var trTag = document.createElement("tr");
tableTag.appendChild(trTag);
for (b = 0; b < t; b++, n++) {
var tdTag = document.createElement("td");
tdTag.innerHTML = n;
trTag.appendChild(tdTag);
}
}
}
createTable(3, 5);
</script>
</body>
</html>