0

I created a button with id="work" when this button is clicked I am trying to redirect to contact us page and the button with id="working- us" is clicked in contact us page.

jQuery

$("#work").click(function() {
    window.location.replace("contactus.html");
    sessionStorage.setItem("workWithUS", "true");
    if (sessionStorage.workWithUs == "true") {
        $("#working-us").trigger(click);
        sessionStorage.removeItem("workWithUs");
    });

HTML

<a href="javascript:void(0);" id="work">Join our Team</a><button class="topic-btn d-flex" data-toggle="tab" href="#working-us" id="work2">
ScottieG
  • 318
  • 2
  • 16

1 Answers1

1

Your code looks OK but it is missing a closing bracket which will likely stop the if statement from triggering:

$("#work").click(function() {
  window.location.replace("contactus.html");
  sessionStorage.setItem("workWithUS", "true");
  if (sessionStorage.workWithUs == "true") {
    $("#working-us").trigger(click);
    sessionStorage.removeItem("workWithUs");
  }
});
DreamTeK
  • 32,537
  • 27
  • 112
  • 171