Below is some typical jquery that I'm working with. As you will see, variables are declared at a global scope (excuse the terminology), however, I wondered if it was also possible to declare a jquery objects the same way that cn, declares class names.
For instance: var jq = { $html : $('html')};
I haven't managed to get any type of syntax to work as yet.
Thanks in advance.
var Nav = function () {
var pub = {},
cn = {
open: "mobile-nav-open"
};
function toggleNav(e) {
e.preventDefault();
$html = $('html');
if ($html.hasClass(cn.open)) {
$html.removeClass(cn.open);
} else {
$html.addClass(cn.open);
}
};
function setupBindings() {
$(document).on("click", "#navicon", toggleNav);
};
pub.init = function () {
setupBindings();
};
return pub;
} ();
=with a:, your question has no sense anymore