JSFiddle - React, Tailwind, and code Playground
by Asmita Jadhav
JavaScript
//var widgetHTML = ' <div id="widget"> <h2>Widget</h2><p>Hi.</p> </div>';
//var widget='<div id="widget"> 45 </div><div id="wid">E123</div>';
//$('#widget').cleanWhitespace();
$(document).ready(
function() {
$('div').text('45\nE123');
}
);
$("div").val(
$("div").html().replace(/\n/g, "")
);
console.log($("div").find("\n"));
jQuery.fn.cleanWhitespace = function() {
textNodes = widgetHTML.contents().filter(
function() { return (this.nodeType == 3 && !/\S/.test(this.nodeValue)); }).remove();
return this;
}