get the right selector
get the right selector
Hello Jquery
I'm pretty new to JavaScript and have ran into a problem. I'm trying to make a simple fade effect where I can fade into diffrent divs and back to the central div (frontpage). My problem is that I have difficulties getting the right selector. Okay this is hard to tell so here is my code:
- $("span").click(function () {
var value = $(this).attr('id');
switch(value)
{
case 'test1':
var whoAmI = "#value1";
$("#value1").fadeIn("slow");
$("#fadeBack").hide();
break;
case 'test2':
var whoAmI = "#value2";
$("#value2").fadeIn("slow");
$("#fadeBack").hide();
break;
case 'back':
//var value = $("div").attr('id');
whoAmI = $(".fade").attr('id');
$("#fadeBack").fadeIn("slow");
$("#"+whoAmI).hide();
break;
}
$('body').append("Value: " + whoAmI);
});
My problem is that if I use a class and an id to selector, I only get the "first" in both cases :(
Anyone who can give me a clue on how to get moving on? And if you need some more information please say so :)