If else statement within Jquery function

Posted by Vafello on Stack Overflow See other posts from Stack Overflow or by Vafello
Published on 2010-03-21T23:15:07Z Indexed on 2010/03/21 23:21 UTC
Read the original article Hit count: 323

I have the following code in Javascript and Jquery:

     $("<li />")

     .html('Somehtml')

I would like to be able to change the content of .html by using 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('Somehtml')     
    else {
      .html('Other html')
      }

Any ideas how should I change it?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript