unemployment Posted June 13, 2011 Share Posted June 13, 2011 I found this snipped of code online, but I don't know what 'e' is. Can someone please explain this to me? I am trying to delete a div when backspace is pressed. function backspace_delete(e) { if (!e) { // IE reports window.event instead of the argument e = window.event; } var keycode; if (document.all) { // IE keycode = e.keyCode; } else { // Not IE keycode = e.which; } if (keycode == { if (document.all) { // IE } else { // Non IE } } } Quote Link to comment https://forums.phpfreaks.com/topic/239234-char-code-event/ Share on other sites More sharing options...
unemployment Posted June 13, 2011 Author Share Posted June 13, 2011 I got this working, but now I have a new issue. Once I have an empty value in my input the event fires, but I only want it to fire if the input field was blank and then I hit backspace, not if I do both of those actions at the same time. if (keycode == 8 && with_field.value == '') { if (document.all) { // IE removeElementById(with_input.lastChild.id); } else { // Non IE removeElementById(with_input.lastChild.id); } } Quote Link to comment https://forums.phpfreaks.com/topic/239234-char-code-event/#findComment-1229082 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.