Maanstraat
Maanstraat

Reputation: 1261

jQuery add text to end of a URL

I have this code:

$('a.comment-reply-link').each(function(){
    this.href = this.href.replace("dummy_comment", "author");
    this.href = this.href.replace("#comment-", "?replytocom=");
});

This is working but now i want on the end of the url #respond. So i made the code as:

$('a.comment-reply-link').each(function(){
    this.href = this.href.replace("dummy_comment", "author");
    this.href = this.href.replace("#comment-", "?replytocom=");
    
    this.href + '#respond';
});

But this is not working? How can i make it work?

Upvotes: 0

Views: 243

Answers (1)

Asad Ullah
Asad Ullah

Reputation: 21

Try changing

this.href + '#respond';

to this

this.href += '#respond';

Upvotes: 2

Related Questions