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 <img draggable="false" class="emoji" alt="🌞" src="36x36/1f31e.png"> how all! ! ! !<img draggable="false" class="emoji" alt="🌻" src="36x36/1f33b.png"> all best<img draggable="false" class="emoji" alt="💪" src="36x36/1f4aa.png"> if above string input! want output like
hello world 1f31e how all! ! ! !1f33b 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 += " " + $(this).attr("src").split('/')[1].split('.')[0] : text += $(this).text(); }); return text; } alert($('body').gettext()); working example : https://jsfiddle.net/dinomyte/2rhasve1/1/
Comments
Post a Comment