如何使用jQuery删除html中的字符

时间:2014-07-27 16:44:28

标签: javascript jquery html css

这是html:

  <div class="upme-field-value">
    <div class="upme-rememberme">
        <i class="upme-icon-check-empty"></i>Remember me
        <input type="hidden" name="rememberme" id="rememberme-1" value="0">
    </div>
    <input type="submit" name="upme-login" class="upme-button upme-login" value="Log In">  
    <br>
    <a href="javascript:void(0);" id="upme-forgot-pass-1" class="upme-login-forgot-link "    
    title="Forget?">Forget?</a> 
    | <-------- **** I want to remove this character****
    <a href="/register/" class="upme-login-register-link 
    ">Register</a> 
  </div>

有没有办法删除此字符“|”从上面的html与jQuery或CSS?

2 个答案:

答案 0 :(得分:2)

这可以解决这个问题

$('div.upme-field-value').html($('div.upme-field-value').html().replace('|',''))

答案 1 :(得分:0)

DEMO

使用此:

$('div.upme-field-value').html(function(i, html) {
    return html.replace(/\|/g,'');
});