Hi there!
I’m a beginner in JS and I have this code line:
[CODE]
var container = $(“#popup_window”);
As you can see, the name of the popup window is hardcoded. How do you write that code line so that I can use a variable name instead? Something like this:
[CODE]
var variable = ‘popup_window’;
var container = $(variable);
Obviously, this doesn’t work.
I need this for a small script that hides a DIV element when you click outside of it. The problem is that I have multiple DIVs and I need to make this code work with all of them. To do that, I have to replace #popup_window with a variable. Here’s the script:
[CODE]$(document).mouseup(function (e) {
var container = $(“#popup_window”);
if (!container.is(e.target) && container.has(e.target).length === 0) {
hide_popup();
}
});
Thank you!
Alex