j3ph — 2010-10-26T12:11:40-04:00 — #1
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:
$("#cell").value($("#cell").substring(0, $("#cell").length() - 1);
It doesn't work Can someone shed some light on what I'm doing wrong.
immerse — 2010-10-26T12:24:45-04:00 — #2
To get or set values of text fields with jQuery you should use .val().
Untested, but something like the following should work:
var el = $("#cell");
var the_value = el.val();
the_value = the_value.substring(0, the_value.length - 1);
I've split the code into several steps to show what's going on.
j3ph — 2010-10-26T12:42:09-04:00 — #3
That worked perfectly. Thank you very much!