user3015600
user3015600

Reputation: 31

Variables in href

I would like to add a variable in an href so that it looks like, or behaves like, this:

var user = "YourName";
$("#main-container .profile-link[href='/home/user/' + player + '/']")

I'm hoping to be able to select all the users that I have in that variable.

Upvotes: 0

Views: 47

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388316

Use proper string enclosures

$('#main-container .profile-link[href="/home/user/' + player + '/"]')

In your case since the string literal is started using " you need to use the same to close the string before the variable is concatenated like "#main-container .profile-link[href='/home/user/" + player + "/']"

Upvotes: 2

Related Questions