Getting resize to work

Getting resize to work

I'm tryng to get my resize function to work in my jquery. What I'm trying to do is if my window size is bigger then 769 then it needs to display my hover menu else it shouldn't display it.

My $(window).load works but not my $(window).resize

Here is my jquery


  
  1. function hover_menu(){
  2. $('ul.navbar-nav li').hover(
  3. function () {
  4. $(this).find('> ul').show();
  5. },
  6. function () {
  7. $(this).find('> ul').hide();
  8. }
  9. );
  10. }

  11. $(document).ready(function(){
  12. $(window).load(function(){
  13. var width = $(window).width();

  14. if(width > 769){
  15. hover_menu();
  16. }
  17. });

  18. $(window).resize(function(){
  19. var width = $(window).width();

  20. if(width > 769){
  21. hover_menu();
  22. }
  23. });
  24. });