javascriptjquerysharepointbranding

How to remove special characters and codes (using jquery) from sharepoint rendered html?


I am Working on a branding of share-point application. In some cases, rendered html contains codes like '​'. In my slider, these are generated 8 times and in modal and content pages, their count is different. These codes are generating undesired white space. How can I remove these using jQuery? I tried to play with this like

$(".wrapper").filter(function(){
  return $.trim(this.innerHTML) === "​";
}).remove();

But its not working.


Solution

  • Check below code which is a bit DOM-intensive but it does work.

    $('#s4-bodyContainer').html($('#s4-bodyContainer').html().replace(/\u200B/g,''));
    

    Let me know if it doesn't work.