javascript - how to call external .js which is inside document.ready by passing in variables from html to call the .js file below -
i'm trying modify function found online. inside document.ready function , if try use function
functionname(variable1,... variablen){}
instade of
$(document).ready(function(){}
it fails. code works pass in variables more stuff. here code , pass in variable. highly appreciated
$(document).ready(function(){ $(".content-slider").slider({ animate: true, change: handlesliderchange, slide: handlesliderslide }); }); function handlesliderchange(e, ui) { var maxscroll = $("#content-scroll").attr("scrollwidth") - $("#content-scroll").width(); $("#content-scroll").animate({scrollleft: ui.value * (maxscroll / 100) }, 1000); } function handlesliderslide(e, ui) { var maxscroll = $("#content-scroll").attr("scrollwidth") - $("#content-scroll").width(); $("#content-scroll").attr({scrollleft: ui.value * (maxscroll / 100) }); }
all functions above in 1 .js file , need call html. call in html this:
<script src="slider_test.js" language="javascript" type="text/javascript">
but way cant input variables
that because document ready literally says: "wait document ready". since need html document these operations. can function call inside of document ready , you'll fine.
Comments
Post a Comment