mercredi 13 juillet 2016

Jquery:Uncaught TypeError: Cannot read property 'top' of undefined

I'm having above error though this Jquery function is working fine.

Jquery:

<script type="text/javascript">
$(document).on('click','.open', function(event) {
    event.preventDefault();
    var target = "#" + this.getAttribute('#context');
    $('html, body').animate({
        scrollTop: $(target).offset().top
    }, 2000);
});
</script>

But because of this there is a link that is not opening.

Html:

<ul class="dropdown-menu ebook">
                <li><a href="ebook.php">Ebooks</a></li>
                <li><a href="research.php">Research Journal</a></li>
</ul>

I've already checked link spelling and other aspects but can't find any solution. Please help me! Thank you

Aucun commentaire:

Enregistrer un commentaire