\$\begingroup\$
\$\endgroup\$
1
How can I make this code snippet be improved to become more professional?
(function($){
$.fn.showMenu = function(options){
return this.each(function(){
$this = $(this);
var high = $this.outerHeight(),
scrollHeight = $this.get(0).scrollHeight;
$this.bind('mouseenter',function(){
$this.css({overflow:'visible'})
.stop()
.animate({height:scrollHeight},'fast');
}).bind('mouseleave',function(){
$this.animate({height:high}, function(){
$this.css({overflow:'hidden'});
});
});
});
}//the end of $.fn.showMenu
$('#theme_content').showMenu();
});
Jamal
35.2k13 gold badges134 silver badges238 bronze badges
-
\$\begingroup\$ Have you considered using CSS animations instead? \$\endgroup\$ANeves– ANeves2012年09月17日 16:10:50 +00:00Commented Sep 17, 2012 at 16:10
2 Answers 2
\$\begingroup\$
\$\endgroup\$
You could also use .hover, if you are going for shorter code. Jquery Hover
\$\begingroup\$
\$\endgroup\$
Proper Indentation. You shouldn't need the
//end of fn
comment. Just indent that entire block.$this = $(this)
needs avar
statement.You wrap your code in a function, which is good, but you need to call that function. The last line should be
})();
answered Sep 14, 2012 at 14:12
default