Reputation: 2884
I'm unable to clear the text box when I hit the button with value C
.
In Opera when I press the number buttons it properly inputs them into the text box but for some reason the C
button never works! Here is the jsfiddle.
Thanks.
Upvotes: 2
Views: 277
Reputation: 70199
Rename your function to something else and it will work.
Now why clear
was giving a conflict is beyond me, console.log
ing it returns undefined
and it's not a keyword AFAIK.
edit: Check Zeta's comment, thanks for the info! clear
is a deprecated function. Reference
Avoid such generic names in the future to skip some headaches. =]
Upvotes: 2
Reputation: 991
function findKeyPressed(e)
{
var codeChar=e.keyCode? e.keyCode : e.charCode
if(codeChar==67)
{
document.getElementById('txtBoxId').value="";
}
}
<input type="text" onkeyup="findKeyPressed(event); this.select()" />
Upvotes: 1
Reputation: 3727
Don't use clear
. Function clear()
is a reserve word I think
http://www.roseindia.net/javascript/javascript-clear-method.shtml
Upvotes: 1