我正在尝试弹出警报,并且我正在使用Visual Studio在我的Firefox上运行它。我现在已经有一段时间了,而且我无法弄清楚错误是什么。
我的代码片段:
<div class="widget-Sidebar">
<div class="header green">
<h1 class="title">Recent Reports</h1>
</div>
<div class="container-blank">
<div class="recent_reports">
<div class="row">
<table>
<tr>
<td>
<div class="title">
<input type="checkbox" id="oneDay" class="reportresponsecheck" /> One Day
</div>
</td>
</tr>
(其余的html代码很好,没有错误)
我的js代码段:
$(document).ready(function () {
$('.reportresponsecheck').click(function () {
alert("11");
var isreportchecked = $("#chkReports").is(":checked");
var isresponsechecked = $("#chkResponses").is(":checked");
var isonedaychecked = $("#oneDay").is(":checked");
alert(isonedaychecked);
CheckUnchekReportResponse(isreportchecked, isresponsechecked);
});
});
非常感谢任何帮助。请告诉我是否需要提供更多详细信息。
答案 0 :(得分:1)
这两个警报都运行良好。试试这个:
$(document).ready(function () {
$('.reportresponsecheck').change(function () {
alert("11");
var isreportchecked = $("#chkReports").is(":checked");
var isresponsechecked = $("#chkResponses").is(":checked");
var isonedaychecked = $("#oneDay").is(":checked");
alert(isonedaychecked);
CheckUnchekReportResponse(isreportchecked, isresponsechecked);
});
});
<强> DEMO 强>
答案 1 :(得分:1)
您的代码中存在语法错误。试试这个
<div class="widget-Sidebar">
<div class="header green">
<h1 class="title">Recent Reports</h1>
</div>
<div class="container-blank">
<div class="recent_reports">
<div class="row">
<table>
<tr>
<td>
<div class="title">
<input type="checkbox" id="oneDay" class="reportresponsecheck" /> One Day
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<script src="http://code.jquery.com/jquery-latest.min.js"
type="text/javascript"></script>
<script>
$(document).ready(function () {
$('.reportresponsecheck').click(function () {
alert("11");
var isreportchecked = $("#chkReports").is(":checked");
var isresponsechecked = $("#chkResponses").is(":checked");
var isonedaychecked = $("#oneDay").is(":checked");
alert(isonedaychecked);
CheckUnchekReportResponse(isreportchecked, isresponsechecked);
});
});//added
</script>
答案 2 :(得分:0)
您在第)
行
CheckUnchekReportResponse(isreportchecked, isresponsechecked);});
尝试
$(document).ready(function () {
$('.reportresponsecheck').click(function () {
alert("11");
var isreportchecked = $("#chkReports").is(":checked");
var isresponsechecked = $("#chkResponses").is(":checked");
var isonedaychecked = $("#oneDay").is(":checked");
alert(isonedaychecked);
CheckUnchekReportResponse(isreportchecked, isresponsechecked);});
});
答案 3 :(得分:0)
你错过了这个“);”
$(document).ready(function () {
$('.reportresponsecheck').click(function () {
alert("11");
var isreportchecked = $("#chkReports").is(":checked");
var isresponsechecked = $("#chkResponses").is(":checked");
var isonedaychecked = $("#oneDay").is(":checked");
alert(isonedaychecked);
CheckUnchekReportResponse(isreportchecked, isresponsechecked);});
});