Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the exact href value only without their domain?

Tags:

jquery

I'm having trouble in getting the exact value of href only. Here is the code:

Link:
<a href="monthly"></a>

Script:
'a': function(target, process){
    if(process == "stripe"){
        document.location.href = "/accounts/stripe/payment"+target[0].href;
    }else{
        ......
    }
},

If I run this the output will be:

http://localhost:8000/accounts/stripe/paymenthttp://localhost:8000/monthly/

Notice that the localhost is duplicating. How to get only the "monthly" in href without that localhost? I try target only but it's undefined. I try target[1] but it's not working.

like image 476
catherine Avatar asked Feb 06 '13 04:02

catherine


1 Answers

Try target[0].getAttribute("href") to get the literal attribute's content.

like image 186
Niet the Dark Absol Avatar answered Sep 19 '22 05:09

Niet the Dark Absol