I have a variable in on load that I wish to access in another script. I wanted the variable runningSlider in onload to be global so that my button function could see it. It doesn't seem to be able to see it, as I get the error messsage: Cannot read property stop of null.
<script type="text/javascript">
$(window).load(function() {
$('#c1').nivoSlider({ effect: 'fade' });
runningSlider = 1;
});
</script>
<script type="text/javascript">
$('#slideButtons button').click(function(){
var newID = $(this).attr("id");
alert (newID);
alert ('test of variable ' + runningSlider);
$('#c' + runningSlider).data('nivoslider').stop();
$('#c' + newID).data('nivoslider').start();
var runningSlider = newID;
});
</script>
Thank you for your help.
})in the first<script>block