November 20th, 2008, 12:48 PM
Trying to truncate a string in JQuery
I have the following code:
<div class="person">John S</div>
Is is possible in JQuery to remove the last letter of the text within the div class "person"?
I'm banging my head off a brick wall trying to figure this out, any help would be greatly appreciated.
Thanks in advance
November 20th, 2008, 03:38 PM
Now, are you trying to just remove the last letter of anything, or are you trying to remove the initial for the person's last name? If you only expect a last initial to be entered, then you can safely stick with just substring(). If, however, you are worried also about full last names, you'll have to turn to split() and use the first part of the returned array, or, worst case, use regex.
I'd rather teach you to fish than give you a fish. I reserve the right to also slap you with the fish.