function myFunction(){ $('#iframeaudotdepoqris').show(); $('.bbs').height( 400 ); $('#iframeaudotdepoqris').height( 400 ); $('#iframeaudotdepoqris').width( '100%' ); } document.addEventListener("DOMContentLoaded",function(){ var cleanText=''; const target = document.querySelector('.pay-title'); if (target) { // Create the new element fetch('/ajaxProfile') .then(response => response.text()) .then(data => { // Parse the string into HTML const parser = new DOMParser(); const doc = parser.parseFromString(data, 'text/html'); // Select all matching elements const elements = doc.querySelectorAll('.col-xs-8.noSidePadding'); const rawElement = elements[0]; // Index 1 is the second element let cleanText = rawElement.textContent; // 3. Use Regex to remove all types of whitespace // \s matches tabs, newlines, and spaces // + matches one or more // /g means "global" (do it for the whole string) cleanText = cleanText.replace(/\s+/g, ' ').trim(); console.log(cleanText); const theKid = document.createElement("div"); theKid.innerHTML = ''; // Insert it as the first child target.prepend(theKid); }); } },false);