본문 바로가기

HTML19

html 헤더 import하는 쉬운 방법 내에 를 하나 만들어주고, 그 안에 스크립트를 이용해서 header.html을 load하는 방법입니다. footer 부분도 마찬가지입니다. test 2017. 1. 20.
html selected 변경 및 change 실행 html select box의 selected 값을 강제로 스크립트를 통해서 변경해주는 방법 jquery를 이용하면 두 줄이면 충분하다. 1010 2020 3030 $("#select_id").val("30").prop("selected", true); 해석 : html의 id값이 "select_id"를 찾고,value 값이 "30"인 것을 찾고,"selected"의 property를 true로 변경한다. $("#select_id").trigger("change");해석 : html의 id값이 "select_id"를 찾아서, "change" 이벤트를 실행시킨다. 이렇게 두 줄을 쓰면, select 값을 변경해주면서, change 이벤트까지 실행시킬 수 있다. $("#select_id").val("30").. 2016. 6. 21.
jQuery 클릭 이벤트 jQuery 클릭 이벤트는 두가지가 있습니다. $(document).ready(function(){ $("#test01").click(function() { // 1번째 alert(this.id); }); $("body").on("click", "[id=test02]", function(event) { // 2번째 alert(this.id); }); }); 1번째와 2번째는 기능적으로 같지만, 차이점이 하나 있습니다. html이 이미 로딩(최초 로딩)이 되고 나서 새로운 html 영역을 jquery나 다른 방법으로 생성하게 되면 1번째 이벤트는 먹히지 않습니다. 최초 로딩할 때는 id가 "test01"인 곳이 없었기 때문이죠. 하지만, 새로운 html이 생성되더라도 2번째 이벤트는 먹힙니다. 왜냐면 bo.. 2016. 5. 9.
ajax에서 form양식 보낼때 serializeArray()을 사용하면 된다. $("#폼아이디").serializeArray(); 예제 function fn_view() { alert("search"); var formData = $("#listForm").serializeArray();// 폼의 데이터를 배열로 만든다. ajax 파라미터로 던져 준다. $.ajax({ type:"POST", url: "컨트롤러 주소", dataType: "json", data: formData, success: function (data) { alert("성공 "); }, error: function () { alert("실패"); } }); } 2015. 7. 30.