$(document).ready(myfunction); $(window).on('resize load',myfunction); function myfunction() { // do whatever }