.hasclass problems

.hasclass problems

i have this code

  1.  $('.paginationli1').click(function(){
                                                                $('#morepostul').load('script.php');
                                                               
                                                                if($('ul#morepostul li').hasClass('morepostli'))                                                           
                                                                {
                                                                    alert('');
                                                               
                                                                 }
                                                                 else
                                                                 { alert('flse');
                                                                     
                                                                     $('ul#morepostul li').addClass('morepostli').css('border','2px solid white');
                                                                   
                                                                 }
                                                                })














it will addClass .morepostli to li only if i mention alert()
otherwise it will not add anything i can't figure out problem

any help appreciated
thank you