내맘대로 살기🎉

[jQuery] iframe에서 checkbox의 값을 가져오기. 본문

개발자의 길/jQuery

[jQuery] iframe에서 checkbox의 값을 가져오기.

해림😶 2017. 4. 26. 08:56
1
2
3
4
$('input[type="checkbox"]',top.window.document).each(function(){
    $(this).attr("checkOutBox",$(this).prop('checked'))
})
 

- 확인되었는지 알 수 있는 attribute를 추가하고, 실제 checkbox의 체크여부를 true, false로 넣어준다.


1
2
3
4
5
6
7
8
$('input[type="checkbox"]').each(function(){
    if($(this).attr('checkOutBox') == "true"){
        this.checked = true;
    }else{
        this.checked = false;
    }
})


- checkOutBox라는 attribute가 있는지 확인하고, 그에 맞게 true, false로 값을 초기화해준다. 


그러면 iframe에서 값이 들어간 것을 확인할 수 있다.


'개발자의 길 > jQuery' 카테고리의 다른 글

[jQuery] textarea의 스크롤 유무 확인  (0) 2017.04.27
Comments