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 } } } 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); } } Link to comment https://forums.phpfreaks.com/topic/239234-char-code-event/#findComment-1229082 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.