What is the difference between the top two lines of javascript here?
HTML:
<html>
<body>
<form>
<input type="button" value="one" id="one" />
<input type="button" value="two" id="two" />
</form>
<script type="text/javascript" language="javascript" src="example.js"></script>
</body>
</html>
javascript:
document.getElementById('one').onclick = one();
document.getElementById('two').onclick = function() {two();}
function one(){
alert('this pops up before the button is clicked. Afterwards, the button doesn\'t work.');
}
function two(){
alert('this pops up appropriately when the button is clicked.');
}
Popone display before the page loads, then the button becomes unusable. Popup two display when the second button is clicked and works appropriately.