This is a basic version of my function (first time I am doing this, so I'm sorry if I don't explain it well)
var pages = {
init:function(){
},
home:function(){
articleid = this.closest("article").attr('id');
skillsbtn = $(this).hasClass("skillsbt");
home = $('#home');
homeheight = '-' + home.height();
if (skillsbtn && articleid == "home"){
home.animate({"marginTop" : homeheight},800);
}
},
work:function(){
//same variables are requred here: skillsbtn = $(this).hasClass("skillsbt");...
},
skills:function(){
//same variables are requred here: skillsbtn = $(this).hasClass("skillsbt");...
},
contact:function(){
},
}
So the idea is skillsbtn = $(this) refer to whatever $(this) is at home:function. I have tried to duplicate the variables from home:function to work:function and it wokeded fine. But can I put the variable I need in the init:function but be able to call them within the home:function and by doing so, be able to change what ever $(this) is, to mean this->home, or this->work
I have tried to access it like pages.init.skillsbtn.call(this) but it dies not work.
Hope you can help - Thanks