0

How i can insert dinamically something like "refer" inside my <> input tag, without writing it directly into html but using javascript? Something similar to

0

2 Answers 2

0

you can use setAttribute for this action

var i = document.querySelector("input");

i.setAttribute("name", "myinput");

ref: https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute

Sign up to request clarification or add additional context in comments.

Comments

0

Supposing you have this 👇

<input type="text" value="23" id="age"> </input>

You can select that element by

const ageInput = document.getElementById('age');

If what you want is to change the text inside you can do this by

ageInput.innerHTML = "Hello World"

Or you can set a new attribute by

ageInput.setAttribute("refer", "true");

setAttribute documentation 👉 https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.