Home > DeveloperSection > Interviews > change the URL for a Hyperlink using jQuery

Posted on    September-08-2012 1:09 AM

 JQuery JQuery 
Ratings:
 1 Answer(s)
  1787  View(s)
Rate this:

AVADHESH PATEL

Total Post:257

Points:1285
Posted on    September-08-2012 12:00 AM

There are three way to change   the URL for a Hyperlink using jQuery.

    1-   $("a").attr("href", "http://www.phpinterviewquestion.com/");

    2-   $("a[href='http://www.phpinterviewquestion.com/']")
            .attr('href',   'http://phpinterviewquestion.com/');
    3-   $("a[href^='http://phpinterviewquestion.com']").each(function(){
            this.href = this.href.replace(/^http:\/\/beta\.phpinterviewquestion\.com/,
          "http://phpinterviewquestion.com");
             });

Don't want to miss updates? Please click the below button!

Follow MindStick