Bones/node_modules/bs-recipes/recipes/webpack.monkey-hot-loader/app/main.js
SOUTHERNCO\x2mjbyrn 7efe7605b8 Template Upload
2017-05-17 13:45:25 -04:00

25 lines
728 B
JavaScript

function inc(value) { // Play with me
return value + 1;
}
function dec(value) { // and me
return value - 1;
}
// IMPORTANT: it won't work as expected if you'll use addEventListener
// or $(document).ready as it will bind events again and again...
// So you may need some workaround for this or split modules in a particular way
window.onload = function() {
var number = document.getElementById('number');
var incBtn = document.getElementById('inc');
var decBtn = document.getElementById('dec');
incBtn.addEventListener('click', function() {
number.innerHTML = inc(+number.innerHTML);
}, false);
decBtn.addEventListener('click', function() {
number.innerHTML = dec(+number.innerHTML);
}, false);
};