Is possible to use jQuery to add this parameter to a mailto:
link?
?subject=Kontakt | ARCOTEL Wimberger Wien
This is the HTML:
<a data-ga-category="Direct contact" data-ga-action="Email" href="mailto:[email protected] " ><span >[email protected]</span></a>
I would like to get this output:
<a data-ga-category="Direct contact" data-ga-action="Email" href="mailto:[email protected]?subject=Kontakt | ARCOTEL Wimberger Wien" ><span >[email protected]</span></a>
Thanks so much!
CodePudding user response:
You can use attr()
to update the value of an attribute. Provide a function to the method call which accepts the current value as an argument, and return the new value, like this:
$('a.picons-envelope').attr('href', (i, href) => href = '?subject=Kontakt | ARCOTEL Wimberger Wien');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<a data-ga-category="Direct contact" data-ga-action="Email" href="mailto:[email protected]" ><span >[email protected]</span></a>