<script type="text/javascript"> $( document ).ready(function(){ $('.pic').mouseenter(function(){ $('.mask', this).css('background-image', 'url("/images/mask/random.php?rand='+Math.random()+'")'); }); }); </script>