Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.
(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();

});

how can I make this code snippet be improved to become more professional?

share|improve this question
Have you considered using CSS animations instead? – ANeves Sep 17 '12 at 16:10

2 Answers

You could also use .hover, if you are going for shorter code. Jquery Hover

share|improve this answer
  1. Proper Indentation. You shouldn't need the //end of fn comment. Just indent that entire block.

  2. $this = $(this) needs a var statement.

  3. You wrap your code in a function, which is good, but you need to call that function. The last line should be })();

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.