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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With