I try to make simple html with javascript for studying html. But when I run the html in browser, it return undefined in console log when trying to get Button 1 and Button 2 value.
Html:
<!DOCTYPE html>
<html>
<script src="js/Try.js"></script>
<head>
<title>Try</title>
</head>
<body>
<div class="wrapper">
<div>
<a type="button" id="Button1" href="#" value="B1" onmouseover="PutValueLog(this)">Button 1</a>
<a type="button" id="Button2" href="#" value="B2" onmouseover="PutValueLog(this)">Button 2</a>
</div>
</div>
</body>
</html>
Javascript:
var tempval;
function PutValueLog(button){
tempval = button.value;
console.log(button);
console.log(tempval);
}
And the console log that I get:
Can anyone tell me why that happen? What I must do to get value not undefined but B1 or B2 in my console log?