checkbox 선택 ie9
$(this).prop('checked', true);
$(this).attr("checked", true);
$(this).attr('checked', 'checked');
3개 중에 하나는 되는 듯...
ie9에서 prop을 썼을 경우에 잘 되었는데,
ie9에서 ajax 로 데이타를 불러와서 레이어를 띄워 checkbox를 control 하는 경우에는 prop이 되지 않았다.
그런 경우에는 $(this).attr('checked', 'checked'); 이 동작을 해서 다행히도 control 가능했다.
<script type="text/javascript" src="/js/common/jquery-1.11.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//default 전체 선택
$('input:checkbox[name="deptpersonchk"]').each(function (){
/*ie9에서 안될 때가 있어서 3개 모두 내버려둠 */
$(this).prop('checked', true);
$(this).attr("checked", true);
$(this).attr('checked', 'checked');
$('input:checkbox[name="allSelect"]').each(function (){
$(this).prop('checked', true);
$(this).attr("checked", true);
$(this).attr('checked', 'checked');
});
});
$('input:checkbox[name="allSelect"]').bind('click', function(){
if($("input:checkbox[name='deptpersonchk']").length != $("input:checkbox[name='deptpersonchk']:checked").length){
$("input:checkbox[name='deptpersonchk']").each(function (){
$(this).prop('checked', true);
$(this).attr("checked", true);
$(this).attr('checked', 'checked');
});
$("input:checkbox[name='allSelect']").each(function (){
$(this).prop('checked', true);
$(this).attr("checked", true);
$(this).attr('checked', 'checked');
});
}else {
$("input:checkbox[name='deptpersonchk']").each(function (){
$(this).prop('checked', false);
$(this).attr("checked", false);
$(this).attr('checked', 'false');
$(this).removeAttr('checked');
});
$("input:checkbox[name='allSelect']").each(function (){
$(this).prop('checked', false);
$(this).attr("checked", false);
$(this).attr('checked', 'false');
$(this).removeAttr('checked');
});
}
});
});
부분을 html 맨 아래로 뺐다.
그리고 해제를 위해서는 $(this).removeAttr('checked'); 를 사용하니 된다.
아.. 그냥 스크립트 부분을 소스 맨 아래로 내렸더니 .prop도 잘 먹는다.