I trying to access value from the input tag but output is showing me null or undefined in console.
<div class="ui-widget">
<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>
</div>
var inputstate = document.getElementById('tags').value;
function addstate(){
console.log(inputstate);
}