mardi 27 octobre 2020

jQuery - Hiding One Div & Showing Multiple Other Divs

http://jsfiddle.net/cEJtA/


$(function () {

    $(".div1, .div2").hide();
    
    $(".link1, .link2").bind("click", function () {

      $(".div1, .div2").hide();        
        
      if ($(this).attr("class") == "link1")
      {
        $(".div1").show();
      }
      else 
      { 
        $(".div2").show();
      }
    });

});

Can anyone please help with this code.

I want 5 divs that work based on the link that's clicked, so there are 5 divs either shown/hidden.

I can do everything except the if/else statement for more divs - any help please?




Aucun commentaire:

Enregistrer un commentaire