Reputation: 859
I'm doing a project that involves a console-like panel. I've looked around on Google, but I can't solve this problem! I got the load() working, but the click() isn't.
<html>
<head>
<script type="text/JavaScript">
function load()
{
document.getElementById("display").innerHTML="Hello!";
}
function click()
{
alert("Clicked");
}
</script>
</head>
<body style="background-color:red;" onload="load()">
<div id="display" style="position:absolute; right:0px; left:0px; bottom:0px; width:100%; height:87%; background-color:white;"></div>
<div style="position:absolute; left:0px; width:10%;">
<b>Input:</b>
<input id="text" maxlength=50 />
<input type="button" onclick="click()" value="OK" />
</div>
</body>
</html>
Help if you can, please! Thanks. :)
Upvotes: 0
Views: 207
Reputation: 1
I experienced the same issue when naming my function clear()
changing the function name fixed the issue
Upvotes: 0
Reputation: 145378
Just rename your click
function to something else, e.g. myclick
and it will work :)
It happens because calling click()
you trigger the click event again but not your function.
Check it here: http://jsfiddle.net/rHyZ7/
Upvotes: 4