javascript - How can I call the jQuery function: animate from outside the html? -


i making website , have picked few things jquery.

the problem when want put function out of index file nothing.

this in index file:

<head> <script src="js/scripts.js" type="text/javascript"></script> <script src="js/jquery-1.11.3.js" type="text/javascript"></script> <script>     $(right()) </script></head> 

and scripts.js contains:

function right() { $("#right").animate({right: '0'}, 800);} 

the #right div inside index file.

try calling script tag inside body rather head. alternatively, if want within head, call within block this:

$( document ).ready(function() {     right(); }); 

for javascript execute, either needs inside body of document, or needs set trigger on event (in case, event "when document ready").


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -