I am stuck with this javascript/jquery code -


http://jsfiddle.net/ytjcl/

so, here code jsfiddle.net

  $(".scroll").click(function(event){      event.preventdefault();      //calculate destination place      var dest=0;      if($(this.hash).offset().top > $(document).height()-$(window).height()){           dest=$(document).height()-$(window).height();      }else{           dest=$(this.hash).offset().top;      }      //go destination      $('html,body').animate({scrolltop:dest}, 1000,'swing');    }); 

here problem, on jsfiddle, code works fine without problems. when try , plugging text editor , run it, developer tools gave warning stating "top" undefined--yet works fine in jsfiddle.

anyone know why so?

::edit:: here what's in

    <head>      <script src="ajax.googleapis.com/ajax/libs/jquery-1.11.0.js"></script>      <script src="bootstrap.min.js"></script>       <meta charset="utf-8">       <meta http-equiv="x-ua-compatible" content="ie=edge">     <meta name="viewport" content="width=device-width, initial-scale=1">     <meta name="description" content="">    <meta name="author" content="">     <link rel="shortcut icon" href="../../assets/ico/favicon.ico">     <script type="text/javascript" src="app.js"></script>        <title>m y | portfolio</title>        <!-- bootstrap core css -->       <link href="bootstrap.min.css" rel="stylesheet">        <link href="carousel.css" rel="stylesheet">         <!-- custom styles template -->       <link href="jumbotron.css" rel="stylesheet">      </head> 

try clicking link throws "top" undefined" error, inspect , check if href attribute defined , not empty.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -