dimanche 12 mai 2019

what is the best way to reduce my code for my on click events?

I see that a majority of my code is hiding the containers, and showing the specific container when I select the proper item on the nav bar. What I am having trouble with is coming up with an if statement, or something that will reduce my code

  // add click event for .dropdown-content
  // if #me clicked hide: $(".container").hide();, main page we'll implement later, and show: $("#aboutMe").show();
  $("#me").click(function() {
    $(".container").hide();
    show: $("#aboutMe").show();
  });
  // else if #port clicked hide: $(".container").hide();, main page we'll implement later, and show: $("#portfolio").show();
  $("#port").click(function() {
    $(".container").hide();
    show: $("#portfolio").show();
  });
  // else if #contact clicked hide: $(".container").hide();, main page we'll implement later, and show: $("#contact").show();
  $("#contact").click(function() {
    $(".container").hide();
    show: $("#cont").show();
  });

Aucun commentaire:

Enregistrer un commentaire