I got into weird problem, here is my code
$(document).ready(function(){
$(".switch-content div:first-child").fadeIn();
$(".switch-content div:first-child").toggleClass("switch-active");
$(".switch-menu ul li").click(function(){
var clicked = $(this).index()+1;
$(this).parent().find("li.switch-active").toggleClass("switch-active");
$(this).toggleClass("switch-active");
$(this).parent().parent().parent().find(".switch-content div.switch-active").fadeOut();
$(this).parent().parent().parent().find(".switch-content div.switch-active").toggleClass("switch-active");
$(this).parent().parent().parent().find(".switch-content div:nth-child("+clicked+")").delay(200).toggleClass("switch-active");
$(this).parent().parent().parent().find(".switch-content div:nth-child("+clicked+")").delay(200).fadeIn();
});
})
var anchor = window.location.hash.substring(1);
var linked = $("#"+anchor).index()+1;
^ this works
When my code is like this, everything works fine, but when I move variables on first spot, my javascript stops working.
var anchor = window.location.hash.substring(1);
var linked = $("#"+anchor).index()+1;
$(document).ready(function(){
$(".switch-content div:first-child").fadeIn();
$(".switch-content div:first-child").toggleClass("switch-active");
$(".switch-menu ul li").click(function(){
var clicked = $(this).index()+1;
$(this).parent().find("li.switch-active").toggleClass("switch-active");
$(this).toggleClass("switch-active");
$(this).parent().parent().parent().find(".switch-content div.switch-active").fadeOut();
$(this).parent().parent().parent().find(".switch-content div.switch-active").toggleClass("switch-active");
$(this).parent().parent().parent().find(".switch-content div:nth-child("+clicked+")").delay(200).toggleClass("switch-active");
$(this).parent().parent().parent().find(".switch-content div:nth-child("+clicked+")").delay(200).fadeIn();
});
^ this doesnt work
Does anyone know why? It makes no sense to me. And I know that my code could be simplier, I'm working on it. :)
Thank you and have a nice day