Creating a Backspace Key
I'm trying to create a button that when pressed will remove the last character entered in a text field called "cell" using jQuery.
Here is what I have:
It doesn't work :) Can someone shed some light on what I'm doing wrong.
$("#cell").value($("#cell").substring(0, $("#cell").length() - 1);
To get or set values of text fields with jQuery you should use .val().
Untested, but something like the following should work:
I've split the code into several steps to show what's going on.
var el = $("#cell");
var the_value = el.val();
the_value = the_value.substring(0, the_value.length - 1);
That worked perfectly. Thank you very much!