<!DOCTYPE html>
<html>
<body>
<p>Click the button".</p>
<input type="text" name="demo" id="demo" value="">
<button value="button" onclick="alert(document.getElementById("demo").value);">Click me</button>
</body>
</html>
This code is not working but document.getElementById("demo").value
replace "this.value" getting result "button".
may be any syntax error or this way of onclick is not working?