Copy pasting the example from bootstrap's web page regarding navigation and search bars:
function thisFunction() {
console.log($("#123").value);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" id="123" type="search" placeholder="Search" aria-label="Search">
<button type="button" class="btn btn-outline-dark" id="456" onclick="thisFunction()">Search</button>
</form>
Why does this give me an undefined? Whereas if I add [0]
it then prints the value?
console.log($("#123")[0].value);
What first element does it fetch this way?