user4591043
user4591043

Reputation:

concatenate variable + selector

how can I concatenate the second line:

 var newLink = $(this).attr("id")

 $("section").load( newLink + "section > *"); // this is not working

newLink is the variable and "section > *" is the selector.thx

Upvotes: 1

Views: 48

Answers (1)

dfsq
dfsq

Reputation: 193261

You need to put space before "section", otherwise CSS selector is incorrect (assuming that there is child section tag within whatever tag newLink points to):

var newLink = $(this).attr("id")
$("section").load(newLink + " section > *");

Note, that you might want to prepend newLink with # if you want ID selector.

Upvotes: 1

Related Questions