treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] what's wron in the code

  • Is this the correct code
    $("#slider_tabs li").click(function(){

    if ($("#slider_tabs li").eq(0)){
    $("#banner1").css("display","block");
    }
    else if ($("#slider_tabs li").eq(1)){
    $("#banner2").css("display","block");
    }
    else if($("#slider_tabs li").eq(2)){
    $("#banner3").css("display","block");
    }
    else if($("#slider_tabs li").eq(3)){
    $("#banner4").css("display","block");
    }
    else ($("#slider_tabs li").eq(4)){
    $("#banner5").css("display","block");
    }

    });
  • It may or may not be the correct code, however it depends on what it's supposed to do!
  • "JSlint will hurt your feelings"
    $("#slider_tabs li").click(function() {

    if ($("#slider_tabs li").eq(0)) {
    $("#banner1").css("display", "block");
    }
    else if ($("#slider_tabs li").eq(1)) {
    $("#banner2").css("display", "block");
    }
    else if ($("#slider_tabs li").eq(2)) {
    $("#banner3").css("display", "block");
    }
    else if ($("#slider_tabs li").eq(3)) {
    $("#banner4").css("display", "block");
    }
    else if ($("#slider_tabs li").eq(4)) {
    $("#banner5").css("display", "block");
    }

    });​