I am using the following code to track the scrolling and I want to put the selected element variables outside the event handler so they are not called each time the user scrolls thereby saving resources. The following only works if I put the first two variables inside the event handler:
var recommend_con_list=$(".recommend_con_list")
var recommend_con=$('.recommend_con')
$(window).scroll(function () {
var y=$(window).scrollTop()
if(y > 82){
recommend_con.css({position:"fixed",top:"0"})
}else{
recommend_con.css({position:"",top:""})
}
});