![](/img/trans.png)
[英]Show a hidden div on click a link after page reload in ajax jquery
[英]Page reload by jquery after ajax function
我的代码正在运行,除了location.reload();
不管用。 我的目的是在取消选中最后一个复选框后重新加载页面。
$(".catcf, .coursetype, .yearcf, .manthcf, .venucf").on('click', function() {
$checkedInputs = $('input.catcf:checked');
$coursetypeInputs = $('input.coursetype:checked');
$yearcfInputs = $('input.yearcf:checked');
$manthcfInputs = $('input.manthcf:checked');
$venucfInputs = $('input.venucf:checked');
if (($checkedInputs.length > 0) || ($coursetypeInputs.length > 0) || ($yearcfInputs.length > 0) || ($manthcfInputs.length > 0) || ($venucfInputs.length > 0) || (styleviwe > 0)) {
// Some AJAX code here...
} else {
// Here I can't reload the page with the last uncheck box but it's not working
location.reload();
}
});
您应该删除最后一个条件:
(styleviwe > 0)
$(".catcf, .coursetype, .yearcf, .manthcf, .venucf").on('click', function() { $checkedInputs = $('input.catcf:checked'); $coursetypeInputs = $('input.coursetype:checked'); $yearcfInputs = $('input.yearcf:checked'); $manthcfInputs = $('input.manthcf:checked'); $venucfInputs = $('input.venucf:checked'); if (($checkedInputs.length > 0) || ($coursetypeInputs.length > 0) || ($yearcfInputs.length > 0) || ($manthcfInputs.length > 0) || ($venucfInputs.length > 0)) { // Some AJAX code here... } else { // Here I can't reload the page with the last uncheck box but it's not working location.reload(); } });
<input class="catcf" type="checkbox" checked /> <input class="coursetype" type="checkbox" checked /> <input class="yearcf" type="checkbox" checked /> <input class="manthcf" type="checkbox" checked /> <input class="venucf" type="checkbox" checked /> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.