admin管理员组文章数量:1279207
I`ve got this link:
<a id="Link" href="mailto:[email protected]?subject=I-Drain Bestellung&body="></a>
Now i want to append data from an form element after &body="
So for example the first time it changes to &body="New text
, and the next time it changes to
&body="New text , Another text
.
How can i do this? Can´t get it to work.. thank you :)
I`ve got this link:
<a id="Link" href="mailto:[email protected]?subject=I-Drain Bestellung&body="></a>
Now i want to append data from an form element after &body="
So for example the first time it changes to &body="New text
, and the next time it changes to
&body="New text , Another text
.
How can i do this? Can´t get it to work.. thank you :)
Share Improve this question edited Jun 11, 2013 at 14:51 Adil Shaikh 44.7k17 gold badges95 silver badges112 bronze badges asked Jun 11, 2013 at 14:50 Marc SterMarc Ster 2,3166 gold badges36 silver badges64 bronze badges 4- 1 More code please so we can adjust it to your needs – lukas.pukenis Commented Jun 11, 2013 at 14:52
- Please post the code which you have tried that did not work. – James Montagne Commented Jun 11, 2013 at 14:53
- Duplicate: stackoverflow./questions/2805742/… – Akrasiac Commented Jun 11, 2013 at 14:56
- i´ve read this before, but solutions didn´t work for my case. – Marc Ster Commented Jun 11, 2013 at 14:58
4 Answers
Reset to default 7You change the attribute of the link:
var link = $('#Link');
link.attr('href', link.attr('href') + 'your text');
You can use pure JS :
var el = document.getElementById('link');
el.href += 'some string';
When possibile, always try to use JS over jQuery, usually, it will provide better performance since it reduce the number of functions call.
For example, you can do it with:
var form = $('.form_element').val();
var el = $('a#Link').prop('href');
el.prop('href', el.prop('href')+form);
$('#Link').attr('href',$('#Link').attr('href')+"New Text")
本文标签: javascriptAppend to the end of an href value with jqueryStack Overflow
版权声明:本文标题:javascript - Append to the end of an href value with jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741251478a2365870.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论