Home » Jquery » javascript –   showing as blank space in WordPress IDE (jQuery)-Exceptionshub

javascript –   showing as blank space in WordPress IDE (jQuery)-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

I’m trying to remove non-breaking spaces on a WordPress site with jQuery + RegEx. I’m using the ‘Custom CSS and JS’ plugin. I know how to do this with code — however, whenever I save the function dealing with  , it’s re-rendered as a blank space in the IDE! So annoying!

Anyway, here’s what I would use if I could:

$("p").html(function (i, html) {
    return html.replace(/ /g, '');
});

but it keeps getting re-rendered as this every time I save:

$("p").html(function (i, html) {
    return html.replace(/ /g, '');
});

And here’s my current (dangerous) workaround — splitting it into two. Obviously this is a terrible long-term solution:

$("p").html(function (i, html) {
    return html.replace(/&n/g, '');
});

$("p").html(function (i, html) {
    return html.replace(/bsp;/g, '');
});

I don’t think targeting blank spaces works for non-breaking spaces; plus, how would avoid getting rid of ALL spaces on the page?

And the :empty jQuery selector doesn’t work either.

Any suggestions?

How to&Answer: