// adding event listener is the best solution to get selected value
// getting input name because datalist value connected with input
<input list="dept_names" id="dept_choose" name="dept_choose" />
<datalist id="dept_names">
<option value="Computer">
<option value="Information">
<option value="Management ">
</datalist>
$(document).ready(function() {
// this is the name from ((Input)) with datalist
var DeptValue = document.getElementsByName('dept_choose')[0];
// Adding Event Listener to get the value
DeptValue.addEventListener('input', function() {
console.log(this.value);
});
});
<input list="ide">
<datalist id="ide">
<option value="Visual Studio Code" />
<option value="Atom" />
<option value="Sublime Text" />
</datalist>
<input list="ide">
<datalist id="ide">
<option value="Visual Studio Code" />
<option value="Atom" />
<option value="Sublime Text" />
</datalist>