开发者

checkbox is unchecked, but is not refreshed in page

I have 2 pages, of which one is a lightbox. When I click cancel in my 开发者_Go百科lightbox, I trigger a function in my parent page to uncheck a checkbox. The state of my checkbox gets unchecked, but the check mark isn't removed. Only if I refresh the page, the check mark is removed. How do I remove the check mark? I am using jQuery.

 <input class="checkbox" type="checkbox" value="krisflyer" id="chkbox"/>
 <a href="lightbox.html?KeepThis=true&TB_iframe=true&height=600&width=950&modal=true" class="thickbox" id="lightbox"></a>
 <input type="hidden" id="cancelfunc" />   //Edited

 $("#cancelfunc").click(function(){
       $("#chkbox").attr("checked", false);
       tb_remove();
 })

In my lightbox:

 <a id="cancel_lightbox" href="#">Cancel</a>  //Edited

 $('#cancel_lightbox').click(function(){
window.parent.$("#cancelfunc").click();
return false;
 })

Update

Sorry, I forgot to mention one thing. I had been using images for the checkbox. If I remove the class that adds the images, the code works fine. The checkbox is checked and unchecked correctly. Only with the images, they do not change appropriately.


Not sure if this will solve it but this is how I would uncheck the box, with removeAttr()

$("#cancelfunc").click(function(){
       $("#chkbox").removeAttr("checked");
       tb_remove();
 });


$("#cancelfunc").click(function(){
       $("#chkbox").checked = false;
       tb_remove();
 })


Try

$("#chkbox").attr("checked", "");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜