开发者

Replace several tags from a text js

I have this pice of text I would like to change:

[¿Cómo se procede cuando la mujer o pareja de un < b>fallecido< /b> pide la congelación del semen]

So I would like to remove ], [ and < b>< /b>

Is there any way to change it everything in the same time??

I tried:

function replaceThings(){
    jQuery(".summary").each(function(){
        var t = jQuery(this).text();
        jQuery(this).text(t.replace(/& lt;/g, ''));
        jQuery(this).text(t.replace('[', ''))开发者_运维技巧;
        jQuery(this).text(t.replace(']', ''));
    });

But only replaces ].

Thanks in advance


function replaceThings(){
    jQuery(".summary").each(function(){
        var t = jQuery(this).text();
        t = t.replace(/& lt;/g, ''));
        t = t.replace('[', ''));
        t = t.replace(']', ''); 
        jQuery(this).text(t);
    });
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜