Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 850543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:16:49+00:00 2026-05-15T07:16:49+00:00

I have written a simple jQuery script that changes the hash tag of a

  • 0

I have written a simple jQuery script that changes the hash tag of a link. I do this because I am using IntenseDebate comments in WordPress but the comment link still links replaced id of the old comments. I’m using jQuery so that if javascript is enabled, the user can click on the comments link and it will take them to the IntenseDebate comments. If its not enabled it will take them to the traditional comments (because IntenseDebate requires javascript to function).

The issue I’m having lies in this script to change the hash tag at the end of the link. Currently the URL “someurl.com/#respond” but I need the script to change it to “someurl.com/#comments“. What is happening is that the script doesn’t work, however I believe my syntax is correct so I decided to try copying and pasting the code into Firebug’s console and the code executed perfectly. I could see that the link I was trying to change was now correct, and I could click on it and it worked as I desired. So what I don’t understand is why the code is not executing when it is supposed to. I am using $(document).ready() and I have other jQuery on the page that executes just fine. I even tested it on a simple HTML page away from all the problems that might be caused by WordPress and I received the same result. Does anyone know why this might be happening?

Here is my code (I am using noConflict because WordPress makes use of other frameworks):

jQuery.noConflict();
jQuery(document).ready(function($) {
$("a[href$='respond']").each(function() { 
    this.href = this.href.replace("respond", "comments");
});
})(jQuery);

Thanks very much for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:16:50+00:00Added an answer on May 15, 2026 at 7:16 am

    You are invoking the result of jQuery(document).ready() that will give you a type error, you are looking for this pattern:

    (function ($) { 
      // inside this function, you can use `$`
      $(document).ready(function() {
        $("a[href$='respond']").each(function() { 
          this.href = this.href.replace("respond", "comments");
        });
      });
    })(jQuery.noConflict());
    

    In the above code you declare an anonymous function that is immediately invoked, passing the result of jQuery.noConflict() as the $ argument to that function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written this simple bit of jQuery that swaps out the containing ul's
I am learning jQuery and I have written a very simple script that works
I have written a simple jquery script for a content slider. My problem is
I have written a very simple script with jQuery, but it does not work
I have written a simple jQuery.ajax function which loads a user control from the
I have written some relatively simple jQuery plug-ins, but I am contemplating writing something
I have written a simple automation script for deploying and restarting my twisted application
I have written a simple WCF service that accepts and stores messages. It works
I'm learning javascript and jquery and have written a very basic script inside my
I have written a very simple JQuery widget to handle fixed toolbars: (function($){ $.fn.stickytoolbar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.