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 :)

Mohammad Adil
  • 44,013
  • 17
  • 87
  • 109
Marc Ster
  • 2,256
  • 6
  • 29
  • 58

4 Answers4

6

You change the attribute of the link:

var link = $('#Link');
link.attr('href', link.attr('href') + 'your text');
René Wolferink
  • 3,498
  • 2
  • 27
  • 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,269
  • 5
  • 49
  • 72
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,589
  • 1
  • 19
  • 38
1
$('#Link').attr('href',$('#Link').attr('href')+"New Text")
hennadiy.verkh
  • 607
  • 1
  • 9
  • 14