skip to Main Content

I have an accordian on a page I am building at https://therussellcons.wpengine.com/services/ and I am trying to add a hyperlink to the "Train the Trainer" title, but can’t seem to figure it out. The title has an empty href since it is used to fire the opening of the accordion, but I need this particular accordion to link to an external url. I’ve tried many different things, but below is what I’ve tried last with no luck.

jQuery(document).ready(function(){
    jQuery("#elementor-tab-title-1832").click(function(){
            $("a.elementor-accordion-title").attr("href", "https://www.test.com");
    });
});

3

Answers


  1. You can put the onclick attribute in your a tag, like this:

    <a href="" onclick="window.open('http://test.com', '_blank')">...</a>
    
    Login or Signup to reply.
  2. If the number of tab titles is a lot and differents, use a variable like redirectUrl.
    Then handle the click event on link by js:

    var redirectUrl = "#";
    jQuery(document).ready(function(){
        jQuery("#elementor-tab-title-1832").click(function(e){
              redirectUrl = "http://test.com";
        });
        //Others tab-title-xxxx click events
        //...
        //...
    
        jQuery("a.elementor-accordion-title").click(function(e){
              e.preventDefault();
              window.location.href = redirectUrl;
        });
    });
    
    Login or Signup to reply.
  3. You have to click twice with this code to get it to work. Is there some other way to do this?

    var redirectUrl = "#";
    jQuery(document).ready(function(){
        jQuery("#elementor-tab-title-1832").click(function(e){
              redirectUrl = "http://test.com";
        });
        //Others tab-title-xxxx click events
        //...
        //...
    
        jQuery("a.elementor-accordion-title").click(function(e){
              e.preventDefault();
              window.location.href = redirectUrl;
        });
    });
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search