Jquery Generate random number pass to if
I'm trying to create a random number in Jquery I'm not sure if I need to
store it to do the next part maybe you guys could help me out on that
first off my random number generator;
$( "#arrowleftup" ).click(function() {
var number = 1 + Math.floor(Math.random() * 10);
$('#storenumber').text(number);
});
I want to generate a random number when my Img with the id "arrowleftup"
is clicked, I then want to pass my number into this -
If ('#storenumber' == 8=>){
$('.battle').show();
} else {
die
};
So that if the number was 8 or higher it would show a hidden div, can
anyone spot the error in my code? Also do I need to store the value to
pass it into the if statement
JSFiddle - http://jsfiddle.net/7t59E/
thanks!
No comments:
Post a Comment