I have a DIV with some characters. How can I remove the last character from the text with each click on the DIV itself?
$("div").on("click", function(){
$(this).text(function(index, text){
return text.replace(/^.(\s+)?/, '');
});
});
$("div").on("click", function(){
$(this).text(function(index, text){
return text.replace(/(\s+)?.$/, '');
});
});
$("div").on("click", function(){
$(this).text(function(index, text){
return text.replace(/r/gi, '');
});
});
See an example of each online at: http://jsfiddle.net/Xcn6s/