JavaScript
-
210927_image,setAttribute(array)JavaScript 2021. 9. 27. 10:27
DOCTYPE html> Insert title here .test{ width: 100px; } .result{ width: 500px; height: 300px; } #img_div{ position: absolute; left: 500px; top: 100px; cursor: pointer; /* 커서포인터 : 링크기능있는 걸 알수있도록 커서모양 바꿔줌 */ } #result_div>img { position: absolute; left: 350px; top: 300px; width: 600px; height: 350px; } /* (방법1) window.onload=function(){ //1.id로 객체 읽어오기..개수가 많을 때는 배열처리 img1=document.getElementById("..
-
210924_window.open/close,버튼,openerJavaScript 2021. 9. 24. 17:40
(dataOpen.html) DOCTYPE html> Insert title here function dataOpen(){ window.open('ex8_dataSend.html','w','width=300,height=200'); /*코드 중에서 'w'는 그냥 아무 이름 붙인 거 */ } 이름 주소 연락처 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (dataSend.html) DOCTYPE html> Insert title here function dataSend(){ /* opener는 현재 열려있는 곳을 의미..여기선 dataopen */ opener.frm.name.value=frm.name.value; opener.frm.addr.value=frm.addr.valu..
-
210924_(랜덤숫자맞추기)innerHTML,이미지JavaScript 2021. 9. 24. 17:31
DOCTYPE html> Insert title here #out{ position: absolute; top: 50px; border: 1px solid gray; width: 300px; height: 200px; padding-left: 10 10px; background-color: #ffc; font-size: 11pt; } var rnd; var cnt=0; window.onload=function(){ rnd=parseInt(Math.random()*100)+1; } function check(su) { /* su를 파라메타값으로 넘김 */ //숫자를 이미지로 변환해서 출력 if(su=10 && surnd) out.innerHTML+=cnt+":"+su+"보다 작습니다 "; //out.inn..
-
210924_setTimeout,setInterval,버튼,이미지JavaScript 2021. 9. 24. 17:31
DOCTYPE html> Insert title here div { position: relative; /* relative 상대적 */ width: 100px; height: 100px; background-color: orange; } var x=100; var intervalId; window.onload=function(){ //2추 뒤에 한번 호출 setTimeout(init,2000); //0.5초마다 주기적으로 호출 intervalId=setInterval(move,500); //멈추려면 clearinterval도 필요하기에 대입함 } function init() { console.log('init호출'); /* box.style.left=x+'px'; box.style.top='100px'..
-
210924_radio,checkbox,innerHTML,spanJavaScript 2021. 9. 24. 17:26
DOCTYPE html> Insert title here table { border: 2px solid gray; width: 500px; } tr,th,td { border: 1px dotted gray; font-size: 10pt; } div { position: absolute; left: 10px; top: 300px; width: 500px; height: 200px; border: 1px solid gray; padding: 20 10px; } ////////////////////////버튼 클릭 이벤트 function disp() { //radiobox var gradeStr="나의 최종학력은 "; //초기값 for(var i=0; i
-
210924_배열,랜덤숫자-이미지(연결되어 출력)JavaScript 2021. 9. 24. 17:21
DOCTYPE html> Insert title here window.onload=function(){ setInterval(rndNum,3000); } function rndNum() { var su=new Array(); for (var i = 0; i < 5; i++) { su[i]=parseInt(Math.random()*9)+1; //중복체크 for (var j = 0; j < i; j++) { if(su[i]==su[j]) { i--; break; } } } for(var i=0;i
-
210924_배열,랜덤이미지JavaScript 2021. 9. 24. 17:18
DOCTYPE html> Insert title here window.onload=function(){ setInterval(rndNum,3000); } function rndNum() { var su=new Array(); for (var i = 0; i < 3; i++) { su[i]=parseInt(Math.random()*9)+1; //중복체크 for (var j = 0; j < i; j++) { if(su[i]==su[j]) { i--; break; } } } console.log(su[0]+","+su[1]+","+su[2]); imge1.src='../image/'+su[0]+'.jpg'; imge2.src='../image/'+su[1]+'.jpg'; imge3.src='../image/'..