I have the following Code for an input field in Bootstrap:
<div >
<label for="f2">F</label>
<input type="text" name="f2" id="f2">
</div>
I also have an external .js script which needs to recieve the information the user inputs. How do I access the user input with my .js script?
CodePudding user response:
By using selector. like that:
const i = document.getElementById('f2');
After this you have access to the input element.
console.log(i.value)
CodePudding user response:
const inputEl = document.getElementById('f2') // get input from the DOM
const inputValue = inputEl.value
