I am trying conditionally set the html content of an element, using the html method on the jquery object.
I am not sure which is the right way to do it. Wether to use an if
statement inside the html method call, or something else
For example I am trying to set different sizes on an image using jquery.
if(settings.imagesize =='1') {
// do something
}
So I tried to put it in the html method as a parameter
.html(if(settings.imagesize=='1') { '<img src="image1.png"/>' })
To give you context for the above code, here is what the complete structure looks like:
for (var i = 1; i <= 25; i++) {
var clone = drop.clone()
.appendTo('body')
.css(direction, Math.random() * jQuery(window).width() - 20)
.css('top', snowTop)
.html(
if (i == '21') {})
}
I am not sure what I am doing wrong, can someone please help me with it?
Thanks.