开发者

Replacing characters with jquery

开发者 https://www.devze.com 2023-01-11 19:30 出处:网络
thanks in advan开发者_StackOverflow中文版ce for your help. I\'m using this piece of code to replace a circumflex a that keeps appearing in a website I\'m working on, however it only replaces the firs

thanks in advan开发者_StackOverflow中文版ce for your help.

I'm using this piece of code to replace a circumflex a that keeps appearing in a website I'm working on, however it only replaces the first occurance of the circumflex a in a given tag.

Can anyone help me extend the code?

    $(function() {
    $('h2, h3, h4, p, a, div, body').each(function() {
        var $h = $(this);
        var html = $h.html();
        html = html.replace( 'Â', '' );
        $h.html( html );
    });
})


Add the "/g" global indicator to your regular expression:

html = html.replace( /Â/g, '' );


Try this:

html = html.replace(/Â/g, '');
0

精彩评论

暂无评论...
验证码 换一张
取 消