[Solved] How to add text before input element using JavaScript?


You can use insertAdjacentHTML.

document.querySelector('input').insertAdjacentHTML('beforeBegin', "item1: ");
<input type="text" name="item1"> 

If you are creating the element dynamically, first append it to an element like the body, and then use insertAdjacentHTML.

var i1 = document.createElement("input");
document.body.appendChild(i1)
i1.insertAdjacentHTML('beforebegin', "Item: ");

2

solved How to add text before input element using JavaScript?