我希望在切换回数据打开后重新加载页面 JSP:
<input type="checkbox" class="expander" id="toggle"
data-on="Portfolio" data-off="Topology" checked
data-toggle="toggle" data-onstyle="success">
</div>
Jquery:
$(document).ready(function() {
var count = 0;
$('#toggle').change(function() {
if (this.checked)
$('#project-list-area').fadeIn('slow'),
$('#topology').fadeOut('slow');
count++;
if (count === 2)
window.location.reload;
else
$('#topology').fadeIn('slow'),
$('#project-list-area').fadeOut('slow');
});
});
最佳答案
您需要在 if
和 else if
超过 1 行时使用括号。
此外,window.location.reload()
是一种方法,因此您需要括号。
$(document).ready(function() {
var count = 0;
$('#toggle').change(function() {
if (this.checked){
$('#project-list-area').fadeIn('slow'),
$('#topology').fadeOut('slow');
count++;
}
if (count === 2)
window.location.reload();
else{
$('#topology').fadeIn('slow'),
$('#project-list-area').fadeOut('slow');
}
});
});
清理了一下,查看toggleFade()
:
$(document).ready(function() {
var count = 0;
$('#toggle').change(function() {
if (this.checked) count++;
if (count === 2) window.location.reload();
$('#topology').fadeToggle('slow'),
$('#project-list-area').fadeToggle('slow');
});
});
关于javascript - 重新打开切换开关后重新加载页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40031922/