Chrome复选框不会更改

时间:2013-03-04 09:15:48

标签: jquery google-chrome checkbox

我在表格中有简单的复选框。这是我在代码中看到的复选框标记:

<input type="checkbox" id="iFact123" onchange="submit_status_change(123,$(this).prop('checked'));" >

现在在Firefox中,这很好用。在Chrome中,会发生以下情况:

  • 单击复选框时,复选框似乎不会更改为选中/取消选中。它保持不变。至少在视觉上
  • submit_status_change()运行正常,如果我重新加载页面,元素将被加载为已检查(现在是数据库中的信息)。由于此函数从$(this).attr('checked'))获取信息,因此必须至少在发送参数时检查该元素 - 它似乎不会出现。

现在有人有任何想法,或遇到过这样的问题吗?

如果您认为它与提交功能有关,那么它是:

function submit_status_change(id, val){
  //$.post('something.php',{'change_status':id, 'status':val}, function(){}); 
}

更新:attr已更改为prop

Chrome现在至少可以直观地更改复选框。 onchange事件似乎没有发生。

火狐:

    TypeError: $(...).prop is not a function
[Break On This Error]   

submit_tech_status(123,$(this).prop('checked'));

UPDATE2:我切断了一些代码。现在提交功能非常清楚。 Firefox在prop时出错,chrome打印没有错误,但没有运行提交功能。这与以前有所不同,其中chrome中的复选框似乎没有被选中或未选中,但功能正常。

1 个答案:

答案 0 :(得分:0)

只需写下:

$("#iFact123").change( function() {
   var c = $(this).prop("checked");
   // do whatever you want with c value
});
相关问题