jQuery cambiar div

I have two div's and I doing this div's change

div class="switchLeft

div class="switchRight" 

<tab> 
(function ($) {  

    $(".switchLeft").click(function () {
        $(this).toggleClass("switchLeft switchRight"); 
    });

})(jQuery);
</tab> 

and I have other two div's I changed the div above, I would like to see that change this div

I have done this but not working:

$(".switchLeft").click(function (){
{ $(this).toggleClass("switchLeft switchRight"); });
var myClass = $(this).attr("class");

if (myClass == "switchLeft") {
    $('.advertTabMenu').hide();
    $('.searchTabMenu').show();
}
else {
    $('.searchTabMenu').hide();
    $('.advertTabMenu').show();
}

};

I can not add code to the site.

preguntado el 29 de julio de 12 a las 10:07

Could you try to clarify the question? It's hard to tell what exactly you're trying to accomplish. -

1 Respuestas

Your code is wrong, you closed the function before the codeblock and hence your statements were never executed.

Tu codigo:

$(".switchLeft").click(function (){
{ $(this).toggleClass("switchLeft switchRight"); });//Closed the function here
var myClass = $(this).attr("class");

if (myClass == "switchLeft") {
    $('.advertTabMenu').hide();
    $('.searchTabMenu').show();
}
else {
    $('.searchTabMenu').hide();
    $('.advertTabMenu').show();
}
};//Invalid syntax

Utilice lo siguiente.

          $(".switchLeft").click(function (){
            {
            $(this).toggleClass("switchLeft switchRight"); 
            var myClass = $(this).attr("class");

            if (myClass == "switchLeft") {
                $('.advertTabMenu').hide();
                $('.searchTabMenu').show();
            }
            else {
                $('.searchTabMenu').hide();
                $('.advertTabMenu').show();
            }

        });

Respondido 29 Jul 12, 10:07

Look at the second line of your code block "});", you closed the function there. - Ashwin Singh

I have a question mr ashwin How do I add sites with the code?I use <tab> CODE </tab>, but not working - Serdar Şengül

RIGHT? BUT NOT WORKING (function ($) { $(".switchLeft").click(function (){ { $(this).toggleClass("switchLeft switchRight"); var myClass = $(this).attr("class"); if (myClass == "switchLeft") { $('.advertTabMenu').hide(); $('.searchTabMenu').show(); } else { $('.searchTabMenu').hide(); $('.advertTabMenu').show(); } }); })(jQuery); - Serdar Şengül

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.