# a

The a SVG element creates a hyperlink to other web pages, files, locations in the same page, email addresses, or any other URL. It is very similar to HTML’s a element.

SVG's a element is a container, which means you can create a link around text (like in HTML) but also around any shape.

Usually, this element is create with:

const a = parentElement.add('a')

It's possible create as a disconnected element with gySVG('a') and attach it to the SVG document with .attachTo().

More info: mdn (opens new window) | w3c (opens new window)

# .href()

a.href( url )

Set the URL or URL fragment the hyperlink points to.

  • argument: {string} url The URL to link

  • returns: {gySVGObject} The original object

const url = element.href();

Get the href current value.

  • returns: {string} The current URL

# .target()

a.target( target )

Set where to display the linked URL.

  • argument: {string} target Some of this values: '_self' | '_parent' | '_top' | '_blank' | <window_name>

  • returns: {gySVGObject} The original object

const target = element.target();

Get the target current value.

  • returns: {string} The target.

# .type()

a.type( mimetype )

Set a MIME type for the linked URL.

  • argument: {string} mimetype A valid MIME Type

  • returns: {gySVGObject} The original object

const mimetype = element.type();

Get the type current value.