Сообщение от link404
|
console.log("click: " + val.value);
|
Замени на
return function(){console.log("click: " + val.value);};
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1251' />
<!--
<script src='https://code.jquery.com/jquery-latest.js'></script>
<script src="https://code.angularjs.org/1.3.9/angular.min.js"></script>
<script src="https://code.angularjs.org/1.3.9/angular-route.js"></script>
-->
<style type='text/css'>
</style>
<script type='text/javascript'>
window.onload = () => {
var buttons = document.getElementsByClassName("btn");
if (buttons.length > 0) {
for (var i = 0; i < buttons.length; i++) {
buttons[i].onclick = receiver(buttons[i]);
}
}
};
function receiver(val) {
return function(){alert("click: " + val.value);};
}
</script>
</head>
<body>
<button type="submit" class="btn btn-primary btn-md" name="point" value="1">button 1</button>
<button type="submit" class="btn btn-primary btn-md" name="point" value="2">button 2</button>
<button type="submit" class="btn btn-primary btn-md" name="point" value="3">button 3</button>
</body>
</html>