0

I want to create variables for each part of the css, however I noticed there is a problem. When I want to dynamically refer to a selector with the variable I created earlier, I've no idea how to write it.

For example:

var defaultAppend = $("p");
var selectFirstDesignerLi = $(".template-seasonFinder .designersToShow li a[data-X=defaultAppend.html()]");

Notice I've reused "defaultAppend" with .html() method added, apparently writing this way will not work.

1 Answer 1

2

You need to use string concatenation like ...a[data-X="+defaultAppend.html()+"]...

var selectFirstDesignerLi = $(".template-seasonFinder .designersToShow li a[data-X="+defaultAppend.html()+"]");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.