Changing javascript variable inside DIV using JQuery

Firstly - I'm not even sure the syntax is correct, but I'm trying to do this, I have a div showing an animated sequence of images that selects a position using a variable.

I'll end up using JSON to feed the changed value, but for now I'm just trying to figure out how to use JQuery to change the variable. Here's the code:

<div id="noiseAnimDiv" style="float: center; background-color: #ffffff; ">
<script type="text/javascript" src="./animatedpng.js">
 </script>
<script type="text/javascript">
var stoptheClock = 3;
    noiseAnim = new AnimatedPNG('noise', './noise/noise0.png', 8, 50);
    noiseAnim.draw(false);
    noiseAnim.setFrameDelay(stoptheClock, 1000); //spin yet stay on value 3
 </script>
</div>

<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).ready(
function() {
    $("#stoptheClock").val(6); //
 }
);
</script>

      

Any help is greatly appreciated

the code is live btw so you can at least see the seq animation http://ashleyjamesbrown.com/fgbp/noise.htm

+3


source to share


1 answer


The library AnimatedPNG

you are using only checks the value of the variable once - on initialization. in your code, you change the value after initializing it.

$(document).ready(
function() {
    $("#stoptheClock").val(6); //
}
);

      

Should be



function() {
    stoptheClock = 6; 
    noiseAnim.draw(false);
    noiseAnim.setFrameDelay(stoptheClock,1000);
}

      

You are not using JQuery for any useful reason in your code, so I removed all the JQuery parts.

+1


source







All Articles