I have the following code in JavaScript and jQuery:
$("<li />")
.html('Some HTML')
I would like to be able to change the content of .html by using an if-else statement. My code should be something like this, however it's not working.
var showinfo = <?php echo '$action'; ?>
$("<li />")
if (showinfo == 'action1'){
.html('Some HTML')
else {
.html('Other HTML')
}
How should I change it?
html, and assign your desired html to that variable in theif..else. Then, call the jQuery once:$("<li />").html(html);