Click function doesn't work first time

ساخت وبلاگ
Hi!

Next function doesn't work first time when menu item is clicked but works after that. It is located just before </body> tag. Any idea why it doesn't work first time?

Code:

<script type="text/javascript">
(function ($, NAME) {       
    var nav = $('ul#primary-menu');               
    nav.find('a').on('click',function(e){               
       
        var $this = $(this),
            $targetContent;
                                               
    $this.closest('[id="primary-menu"]').find('a').removeClass('current');
    $this.addClass('current');
                                               
    $targetContent = this.getAttribute('href');               
     
    });
       
})(jQuery);

</script>

CodingForums...
ما را در سایت CodingForums دنبال می کنید

برچسب : نویسنده : codingforums بازدید : 160 تاريخ : يکشنبه 15 مرداد 1396 ساعت: 8:34