프로그램 소개: http://simulz.com/462 초기화 버튼 토글 var toggleResetButton = function() { if($('#list :checked').length) { $('#reset').attr('disabled', false); } else { $('#reset').attr('disabled', true); } } if($('#list :checked').length) ID가 list인 객체에 속해있는 체크박스 중 속성이 checked인 객체들이 있으면, jQuery는 객체가 없어도 값을 반환하므로 .length로 검사해야 한다. $('#reset').attr('disabled', false); ID가 reset인 객체(BUTTON)의 disabled 속성을 제거한다.
프로그램 소개: http://simulz.com/462 프리셋으로 선택하기 미리 설정된 CCTV들을 자동으로 선택한다. $('#left_foot button').click(function(){ $('#list :checkbox').attr('checked',false).parent().removeClass('checked'); $.each(cctv_preset(this.id), function() { $('#c' + this).attr('checked',true).parent().addClass('checked'); }); toggleResetButton(); }); $('#left_foot button') ID가 left_foot인 객체에 속해있는 하위 엘레멘트인 button 객체들을 가리킨다. .cl..
프로그램 소개: http://simulz.com/462 CCTV 직접 선택하기 DIV 영역 또는 체크박스를 클릭하면 선택이 된다. $('#list div').click(function(event) { var $check = $(this); if($check.is(':not(.checked)')) { $check.addClass('checked').find(':not(:checked)').attr('checked',true); }else if($check.is('.checked')) { $check.removeClass('checked').find(':checked').attr('checked',false); } mouseOver.call(this, event); toggleResetButton(); })..
1 text Key1=Value1&Key2=Value2 처럼 보내기 $(document).ready(function() { $('form').submit(function() { $.post('query.php', $(this).serialize(), function(data) { // 받은 데이터를 처리 }); return false; }); }); .serializeArray() 는 항목을 배열로 넘길 때 사용한다. 다른 항목은 생략... 위와 같은 폼을 서버로 보낸다고 할 때 .serialize()로 보내면 서버에서는 $_REQUEST['c0'], $_REQEUST['c1'], $_REQUEST['다른항목'] 처럼 따로 처리를 해야 한다. .serializeArray()로 배열로 만들고 변수에 담아서..