[英]Getting User Input Value from Bootstrap Form
I have the following Code for an input field in Bootstrap:我在 Bootstrap 中的输入字段有以下代码:
<div class="form-group">
<label for="f2">F</label>
<input type="text" class="form-control" name="f2" id="f2">
</div>
I also have an external.js script which needs to recieve the information the user inputs.我还有一个 external.js 脚本,它需要接收用户输入的信息。 How do I access the user input with my.js script?
如何使用 my.js 脚本访问用户输入?
By using selector.通过使用选择器。 like that:
const i = document.getElementById('f2');
像这样:
const i = document.getElementById('f2');
After this you have access to the input element.在此之后,您可以访问输入元素。
console.log(i.value)
const inputEl = document.getElementById('f2') // get input from the DOM
const inputValue = inputEl.value
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.