如何在第二次点击时关闭 div?
How to close a div on second click?
我在手机版上第二次点击无法关闭div,当我第二次点击它时它会重新打开,如果我点击另一个我可以关闭div 但是 div 打开所以我必须重新加载页面以关闭 divs...
JAVASCRIPT:
$(document).ready(function () {
$(window).on("resize", function (e) {
checkScreenSize();
});
checkScreenSize();
function checkScreenSize() {
var newWindowWidth = $(window).width();
if (newWindowWidth < 768) {
$(document).ready(function () {
$('.hero-overlay-block-1').click(function () {
$('.block-uzo').slideToggle("slow");
$('block-uzo').css('display', 'block');;
$('.block-more-1').hide();
$('.block-misija').hide();
$('.block-vizija').hide();
});
});
$(document).ready(function () {
$('.hero-overlay-block-2').click(function () {
$('.block-misija').toggle("slow");
$('.block-misija').css('display', 'block');;
$('.block-more-2').hide();
$('.block-uzo').hide();
$('.block-vizija').hide();
});
});
$(document).ready(function () {
$('.hero-overlay-block-3').click(function () {
$('.block-vizija').toggle("slow");
$('block-vizija').css('display', 'block');;
$('.block-more-3').hide();
$('.block-uzo').hide();
$('.block-misija').hide();
});
});
}
}
});
<script>
$(document).ready(function(){
$(".desc_div").slideUp();
$(".open_div").click(function(){
if($(this).hasClass('selected')){
$(this).removeClass('selected');
$(this).addClass("selected").next(".desc_div").slideUp("slow", function() {
$(this).prev().removeClass('selected');
});
}
else{ $(this).addClass("selected").next(".desc_div").slideDown("slow");
}
});
});
</script>
我在手机版上第二次点击无法关闭div,当我第二次点击它时它会重新打开,如果我点击另一个我可以关闭div 但是 div 打开所以我必须重新加载页面以关闭 divs... JAVASCRIPT:
$(document).ready(function () {
$(window).on("resize", function (e) {
checkScreenSize();
});
checkScreenSize();
function checkScreenSize() {
var newWindowWidth = $(window).width();
if (newWindowWidth < 768) {
$(document).ready(function () {
$('.hero-overlay-block-1').click(function () {
$('.block-uzo').slideToggle("slow");
$('block-uzo').css('display', 'block');;
$('.block-more-1').hide();
$('.block-misija').hide();
$('.block-vizija').hide();
});
});
$(document).ready(function () {
$('.hero-overlay-block-2').click(function () {
$('.block-misija').toggle("slow");
$('.block-misija').css('display', 'block');;
$('.block-more-2').hide();
$('.block-uzo').hide();
$('.block-vizija').hide();
});
});
$(document).ready(function () {
$('.hero-overlay-block-3').click(function () {
$('.block-vizija').toggle("slow");
$('block-vizija').css('display', 'block');;
$('.block-more-3').hide();
$('.block-uzo').hide();
$('.block-misija').hide();
});
});
}
}
});
<script>
$(document).ready(function(){
$(".desc_div").slideUp();
$(".open_div").click(function(){
if($(this).hasClass('selected')){
$(this).removeClass('selected');
$(this).addClass("selected").next(".desc_div").slideUp("slow", function() {
$(this).prev().removeClass('selected');
});
}
else{ $(this).addClass("selected").next(".desc_div").slideDown("slow");
}
});
});
</script>