I’m trying to hide a div when a page loads, if the number within the span is 0.
Here’s what I tried using, which did not work:
$(document).ready(function() {
var x = $("span#number").val();
if (x = 0){
$("div#container").hide();
};
});
Here’s the fiddle I set up: http://jsfiddle.net/Cmsvj/
How do I make this work?
For span elements you should use
text()method instead of theval(), also in the if statement change the=operator with==, currently instead of comparing the value you are assigning the value:DEMO