jquery - Javascript String replace -


i wanted know how following function in javascript or jquery! there function return following string. have write function convert input given shown below.

hello world&nbsp;<img draggable="false" class="emoji" alt="🌞" src="36x36/1f31e.png">&nbsp;how all! ! ! !<img draggable="false" class="emoji" alt="🌻" src="36x36/1f33b.png">&nbsp;all best<img draggable="false" class="emoji" alt="💪" src="36x36/1f4aa.png"> 

if above string input! want output like

hello world&nbsp;1f31e&nbsp;how all! ! ! !1f33b&nbsp;1f4aa 

how this.. please suggest me best possible way!

thank in advance!!

you $('body').text() if had no encoded characters unfortunately $.text() automatically decodes them. in order around it, need write custom function.

$.fn.gettext = function() {   var text = '';   $(this).contents()     .filter(function() {        $(this).text() == "" ? text += "&nbsp;" + $(this).attr("src").split('/')[1].split('.')[0]  : text += $(this).text();     });     return text; }  alert($('body').gettext()); 

working example : https://jsfiddle.net/dinomyte/2rhasve1/1/


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -