通过 Jquery 将参数添加到 "mailto:"
Add parameter to "mailto:" by Jquery
是否可以使用 jQuery 将此参数添加到 mailto:
link?
?subject=Kontakt%20%7C%20ARCOTEL%20Wimberger%20Wien
这是HTML:
<a data-ga-category="Direct contact" data-ga-action="Email" href="mailto:wimbergerr@arcotel.com " class="picons-envelope"><span class="pl-2">wimbergerr@arcotel.com</span></a>
我想得到这个输出:
<a data-ga-category="Direct contact" data-ga-action="Email" href="mailto:wimbergerr@arcotel.com?subject=Kontakt%20%7C%20ARCOTEL%20Wimberger%20Wien" class="picons-envelope"><span class="pl-2">wimbergerr@arcotel.com</span></a>
非常感谢!
您可以使用 attr()
更新属性值。为接受当前值作为参数的方法调用提供一个函数,return 新值,如下所示:
$('a.picons-envelope').attr('href', (i, href) => href += '?subject=Kontakt%20%7C%20ARCOTEL%20Wimberger%20Wien');
<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:wimbergerr@arcotel.com" class="picons-envelope"><span class="pl-2">wimbergerr@arcotel.com</span></a>
是否可以使用 jQuery 将此参数添加到 mailto:
link?
?subject=Kontakt%20%7C%20ARCOTEL%20Wimberger%20Wien
这是HTML:
<a data-ga-category="Direct contact" data-ga-action="Email" href="mailto:wimbergerr@arcotel.com " class="picons-envelope"><span class="pl-2">wimbergerr@arcotel.com</span></a>
我想得到这个输出:
<a data-ga-category="Direct contact" data-ga-action="Email" href="mailto:wimbergerr@arcotel.com?subject=Kontakt%20%7C%20ARCOTEL%20Wimberger%20Wien" class="picons-envelope"><span class="pl-2">wimbergerr@arcotel.com</span></a>
非常感谢!
您可以使用 attr()
更新属性值。为接受当前值作为参数的方法调用提供一个函数,return 新值,如下所示:
$('a.picons-envelope').attr('href', (i, href) => href += '?subject=Kontakt%20%7C%20ARCOTEL%20Wimberger%20Wien');
<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:wimbergerr@arcotel.com" class="picons-envelope"><span class="pl-2">wimbergerr@arcotel.com</span></a>