I want to dynamically create an <a href="mailto:...">
element, then "click" it. All without modifying the page.
I'm trying this:
$('<a href="mailto:[email protected]"> </a>').click();
...to no avail
Answer: Use the jQuery . attr() Method You can use the jQuery . attr() method to dynamically set or change the value of href attribute of a link or anchor tag.
Answer: Use the jQuery click() Method You can use the click() method to trigger a click on a link programmatically using jQuery.
You can use jQuery DOM manipulation methods like append(), appendTo() or html() to add new HTML elements like div, paragraph, headings, image into DOM without reloading the page again.
Its not jquery, but it works just fine.
var link = document.createElement('a');
link.href = url;
document.body.appendChild(link);
link.click();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With