Issue
I trying to access value from the input tag but in console it showing me undefined or null
<div class="searchbar">
<input type="text" id="tags" placeholder="Search for a state...">
</div>
button type="button" id="add-btn-data" onclick="addstate()">add</button>
var inputstate = document.getElementById('tags').value;
function addstate(){
console.log(inputstate);
}
Solution
Try to declare variable inside the function it might work
function addstate(){
var inputstate = document.getElementById('tags').value;
console.log(inputstate);
}
Answered By - ADARSH BHARDWAJ
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.