Search code examples
javascripttargets

adding target property to this JS code


I want to edit this code:

this.link = $('<a>Directions</a>').addClass('mapplic-tooltip-link').attr('href', '#').hide().appendTo(this.el);

to open in a new window. I've looked online but I don't know how to edit this. Any help would be much appreaciated.


Solution

  • try this

    this.link = $('<a>Directions</a>')
                .addClass('mapplic-tooltip-link')
                .attr('href', '#')
                .attr('target', '_blank').hide().appendTo(this.el);
    

    just add another property attr to your link with the target key and blank value.