I have been working on a pi calculator in javascript for a long time now and I have finally finished. The problem is that my script in the head section:
document
Wrap it on a window onload
event:
window.onload = function()
{
document.getElementById("button").addEventListener('click', (function(){
alert('Beginning…');
}), false);
};
or
window.addEventListener('load', function()
{
document.getElementById("button").addEventListener('click', (function(){
alert('Beginning…');
}), false);
});
or, if your script doesn't have to be in the head, put it after the element that has the id of button.
DEMO