1

I`ve got this link:

<a id="Link" href="mailto:bestellung@i-drain.net?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 :)

Adil Shaikh
  • 44,509
  • 17
  • 89
  • 111
Marc Ster
  • 2,276
  • 6
  • 33
  • 63

4 Answers4

7

You change the attribute of the link:

var link = $('#Link');
link.attr('href', link.attr('href') + 'your text');
René Wolferink
  • 3,558
  • 2
  • 29
  • 43
2

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.

Karl-André Gagnon
  • 33,662
  • 5
  • 50
  • 75
1

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);
realshadow
  • 2,599
  • 1
  • 20
  • 38
1
$('#Link').attr('href',$('#Link').attr('href')+"New Text")
hennadiy.verkh
  • 972
  • 2
  • 11
  • 16