To take the data from the form and paste in the html code with JS\JQuery?

Asking for help from the knowledgeable:

How to make the data from the form were substituted into the html code using JS or JQuery?

A simple example:
<input type="text" id="form">

<a href="domain.com?var=[x]" id="link">link</a>


You need to when you enter in the text shape, the text was immediately set up in the link.
How to do it? Thank you.
July 2nd 19 at 13:52
2 answers
July 2nd 19 at 13:54
Solution
$("#form").change(function(){
$("#link").attr("href","domain.com?var="+$(this).val());
});

Something like that.
July 2nd 19 at 13:56
<input type="text" onchange="pasteIntoLink(this.value);">
<a href id="link">My link</a>

var link = document.getElementById('link');
pasteIntoLink function(value) {
 link.setAttribute('href', https://domain.com?var=value);
}
Thank you! - Doris_Hudson41 commented on July 2nd 19 at 13:59

Find more questions by tags Web DevelopmentJavaScriptHTMLjQuery