Answer the question
In order to leave comments, you need to log in
How on button click from textarea/input put text in a href?
How to make an input field in native js that, on button click, will replace the content of ahref with the content of textarea/input?
<textarea name="siteaddress" cols="150" rows="5"></textarea>
<button name="open">Открыть</button>
<a href="https://learn.javascript.ru/"></a>
Answer the question
In order to leave comments, you need to log in
const button = document.querySelector(`.open`); // изменить name на клас
const textarea = document.querySelector(`.siteaddress`);
const link = document.querySelector('a');
button.addEventListener(`click`, (e) => {
e.preventDefault();
link.href = textarea.value;
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question