본문 바로가기

HTML│CSS│Java Script34

html 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 removeChild, parentNode, replaceChild onload=function(){ //부모 노드에서 자식 노드 삭제 document.getElementById("div").removeChild(p2); //자식 노드에서 부모노드에 접근 document.getElementById("str").parentNode.parentNode.removeChild(p4); var div = document.getElementById("str").parentNod.. 2017. 12. 6.
html 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 32 33 34 35 36 37 DOM /* 요소 선택자 */ div{background-color:skyblue;height:100px} function change_go(){ document.getElementById("mydiv").style.background="yellow"; } /*body 부분의 구조를 읽고 난 뒤에 실행하세요*/ /*페이지 로드 이벤트*/ window.onload=function(){ var btn1=document.getElementById("btn1"); btn1.onclick=function(){ document.getE.. 2017. 12. 6.
html 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 동일 요소 검색 : getElementsByTagName onload = function(){ document.getElementById("btn").onclick = function(){ var count = document.getElementsByTagName("li"); //alert(count.length);//10 var s =""; for (var i = 0; i 2017. 12. 6.
html 경고창 , 현재 시간 출력 예제 html 예제 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 32 콜백함수a // 콜백함수 ; 함수를 하나의 자료형처럼 취급 // 즉 함수를 다른 함수의 매개변수로 사용 function send_go() { setTimeout(function() { alert("경고메세지") ; }, 3000); } function send_go2() { var now = new Date(); var s = now.getFullYear()+". " + (now.getMonth()+1)+". "+ now.getDate()+" "+ now.getHours()+" : " + now.getMinutes()+" : "+now... 2017. 12. 6.
html 예제 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 Number Methods //Nan : 숫자가 들어갈 자리에 숫자가 아닌 다른 값이 들어오면 표시 //isNan : Nan 확인 //Number() : 숫자형 문자를 숫자로 바꾼다. 잘못 들어오면 Nan표시 //parseInt : 정수 변환 //parseFloat : 실수 변환 document.write(Number("10")+" ");//10 document.write(Number("10.33")+" ");//10.33 document.write(Number("10 20 30")+" ");//Nan document.write(Number("10 years").. 2017. 12. 6.