JQuery 36

211006_

DOCTYPE html> Insert title here $(function () { //정적이벤트 //최초에만 가능하고 추가된 element에는 버튼 추가 기능이 없음(부모의 이벤트 없음) /* $("button[name='add']").on("click", function() { $('body').append("B"); }); */ //동적이벤트 가능하게 변경 //추가된 element에 계속해서 부모의 이벤트를 가질 수 있게 만든다 //on(이벤트, 지정자, 구현부function) $(document).on("click", "button[name='add']", function() { $('body').append("B"); }); }); B

JQuery 2021.10.06

211006_on(동적/정적)

//on: 1.8이전에는 live 사용 //처음부터 존재하는 요소나 미래에 생기게 될 요소에 모두 이벤트 가능 DOCTYPE html> Insert title here $(function () { //jquery on("click")과 click() 차이 //동적으로 이벤트를 바인딩할 수 있는지의 차이 //click()은 최초에 선언된 element에만 동작 가능 //두번째 파라메타에선 지정자를 선택 가능..on("click",지정자,,function()) /* //정적이벤트 $("#mylang").children().click(function() { $(this).remove(); }); //li태그 추가 //정적인 이벤트는 추가된후 삭제 안됨(최초에 선언한 엘리멘트만 동작가능) $("#mylang")..

JQuery 2021.10.06

211006_array,each

DOCTYPE html> Insert title here div.box { border: 5px solid tomato; margin-top: 20px; width: 300px; height: 120px; padding: 20px 20px; font-family: 'Nanum Pen Script'; font-size: 1.3em; } 배열반복시 사용하는 $.each문 var data1=["magenta","blue","orange","gray","yellow","green"]; /* i는 인덱스로 0번부터, elt는 element(인덱스에 해당하는 아이템값)로 생략가능 */ $.each(data1, function(i, elt) { var s=""+elt+""; document.write(s); }); ..

JQuery 2021.10.06

211006_div,click,hide,show

DOCTYPE html> Insert title here .red{color: red;} .green{color: green;} .blue{color: blue;} /* 그냥 b만 써도 되나 관계공부를 위해 */ /* div의 content red,green,blue를 한꺼번에 부를려면 공통단어인 content */ div.content>b{ cursor: pointer; font-family: 'Nanum Pen Script'; font-size: 25pt; } /* 그냥 h5로 해도 됨 */ div.answer>h5 { text-indent: 30px; /* 들여쓰기 */ } $(function() { //댓글숨기기 $("div.answer").hide(); //내용 클릭시 그 내용의 댓글만 보이고 ..

JQuery 2021.10.06