How can I write
var menu = $('.something');
and use it in an external .js file like so:
$(menu).attr("class", "active");
I have also tried declaring the external js file after the inline code and it will not work.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As long as you define
menubefore you import the external js file that references it, I don’t see why it wouldn’t work. Like:Give that a try.