用空格替换元素值的javascript

时间:2015-07-13 20:52:10

标签: javascript html

我希望将包含$符号的tspan替换为空的tspan可能是一个空格。有没有办法在加载页面时在整个项目中替换它?

1 个答案:

答案 0 :(得分:0)

Assuming the original version of your question was what you meant (to display HTML, you need to enclose them in back quotes, e.g. <tspan>):

To replace every <tspan class="symbol">$</tspan> with <tspan> </tspan>, this is one way to do it:

$(
    $('tspan.symbol').each(function() {
        if ($(this).text() == '$') {
            $(this).removeClass('symbol');
            $(this).text(' ');
        }
    });
);