I am really new to javascript objects.
Here is my code:
(function(){
var homenavmenu = {
nav:$('.navMenuButton'),
target:$(this).attr('href'),
test:function(){
// alert(homenavmenu.target)
homenavmenu.nav.click(function(){
alert(1);
return false;
})
}
}
homenavmenu.test();
})()
Why doesn't it work? It won't alert(1);
Here is my HTML:
<div class="navMenu">
<a href="../market" class="navMenuButton" id="mo">market</a>
<a href="../unit" class="navMenuButton" id="unit">my</a>
</div>
homenavmenu....$at the front of your dom ready method :)$(function() { /* code here */ });