JQuery更改功能在safari浏览器中不起作用

时间:2017-08-18 20:36:18

标签: javascript jquery google-chrome safari

我有一个单选按钮和复选框

<div class="counter_p" id="counter"></div>

我希望在选择这些按钮时收到通知

<input type='radio' name='testradiochange' id='testradiochange'> Testing Radio Change</input>

<input type='checkbox' name='acknowledge' id='acknowledge' value='acknowledge'></input>

以上在Chrome和Firefox中运行良好,但在Safari中则无效。任何的想法?

1 个答案:

答案 0 :(得分:2)

您的代码中有很多拼写错误,以下是:

<div class="container">
  <div class="item">
  </div>
</div>
<div class="footer">
</div>
$("input[name=testradiochange]:radio").change(function () {
    alert('radio selected');    
}); // <= it was just }, i added ); to close the function's (

$("input[name=acknowledge]:checkbox").change(function () {
    if ($(this).is(':checked')) { // if check
    	alert('checkbox selected');    
    } else {                      // if uncheck
    	alert('checkbox unselected');
    }
 }); // <= it was just }, i added ); to close the function's (