jquery - Javascript: How to remove the last character from a div or a string? -


i have div string of content in it. content not stored in variable , remove last character of text in div. please?

more info:


i have text field, , upon entering text text field, text appears in div in large writing. when user hits back-space key, want last character in div deleted. using jquery achieve this. here code:

$(document).ready(function(){     $("#theinput").focus();   //theinput text field      $('#theinput').on('keypress', printkeypress);      function printkeypress(event)     {         //#mainn div  hold text         $('#mainn').append(string.fromcharcode(event.keycode));         if(event.keycode ==8)   //if backspace key, below         {             $('#mainn').empty();  //my issue located here...i think         }     }  }); 

i have attempted $('#mainn').text.slice(0,-1);

i have tried storing value of #theinput in variable , printing it, didn't work. ideas ?

$('#mainn').text(function (_,txt) {     return txt.slice(0, -1); }); 

demo --> http://jsfiddle.net/d72ml/8/


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -