Question: I have an `<a>` for "Log in" as `<a href="#" id="login">Log in</a>`. 

I'd like to replace the body of the `<a>` only when the url is on a certain page. How might you go about doing that with jQuery?

**Clarification:** When I'm at my `/login` URL, I want to change the `<a>` from:

`<a href="/login">Log in</a>`

to

`<a href="/signup">Sign up</a>`

I have the following jQuery but don't know how to apply it to the specific link when the user is on a certain page.

```
$('a#login').html('<a href="/">Sign up</a>');

```

Answer: 
site url : /login

```
<a href="#" id="login">Log in</a>

```

if you wanna replace it, do like this

```
$(function(){
    var url = document.location.href;
    var site = url.split('/');

    if( site[site.length-1] === 'login')
        $('a#login').replaceWith('<a href="/signup">Sign up</a>');
});

```

but if you just want to replace the 'text' and 'href', do like this

```
$(function(){
    var url = document.location.href;
    var site = url.split('/');

    if( site[site.length-1] === 'login')
        $('a#login').text('Sign up').attr('href','/signup');
});

```

hopefully help :D
You can do like this,

```
<a id="login" href="#">Log in</a>.

```

Jquery,

```
 var currentUrl=window.location;
    if(currentUrl=="url"){
       $('a#login').attr('href','new url')
    }

```