0

Here is the 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>

Is There is a way to remove this character "|" from the above html with jQuery or CSS?

0

2 Answers 2

2

This will work in this problem

$('div.upme-field-value').html($('div.upme-field-value').html().replace('|',''))
Sign up to request clarification or add additional context in comments.

4 Comments

Simple but effective.
@AlexDouglas: This is an anti-pattern that shouldn't be used. It's silly to destroy and recreate a section of the DOM just to remove a single text character. You should target the <a> element just before the character, then remove the next text node. Much faster and less destructive.
...Do it like this: var a = document.getElementById("upme-forgot-pass-1"); a.parentNode.removeChild(a.nextSibling);, or use a jQuery equivalent if you prefer slower code.
@cookiemonster Thanks buddy, I'll use your method instead :)
0

DEMO

Use this:

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

7 Comments

You should definitely not use reg ex in this case.
Because it is only one, right? I'll update the answer.
Because it is preferable to do a basic string to string replacement when it is possible.
If there are more | characters it only the first would be removed if you did a simple replace.
@ValentinMercier and that is based on what criteria?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.