jwaltz
jwaltz

Reputation: 125

Replacing links with var

I am trying to replace a link with a var but the page being loaded is example.com/$NewLink instead of the value of the variable, I am sure this has been asked already but I could not seem to strum up the answer.

Current Code:

$('[href="Link"]').attr('href', '$NewLink');

Thanks

Upvotes: 1

Views: 32

Answers (2)

Eye
Eye

Reputation: 1

Remove the quotes around $NewLink

Upvotes: 0

random_user_name
random_user_name

Reputation: 26180

$NewLink is a variable, not a string. Remove the quotes:

$('[href="Link"]').attr('href', $NewLink);

Upvotes: 2

Related Questions