Question: i have trapped in a jquery function, all i want is to append some divs using jquery's append function, but the problem is that i want to put some if conditions in this function, 

here is my working code without condition

```
$( "#some-div-container" ).append( 
                                  "<div>name 1" +
                                      "<a href=\"#\">" +
                                           "<div id=\"add\">Add</div>" +
                                      "</a>" +
                                      "<div>Available</div>" +
                                  "</div>"
                                );

```

i am using jquery's ajax function having some json response, so i want just that, let say if(response == 1) then execute the code inside it, i am trying using condition, 

```
 $( "#some-div-container" ).append( 
                                  "<div>name 1"
                                  if(response == 1) {    
                                     +"<a href=\"#\">" +
                                           "<div id=\"add\">Add</div>" +
                                      "</a>"
                                  }
                                      + "<div>Available</div>" +
                                  "</div>"
                                );

```

is it possible?
Any help will be appreciated, an error occured when i put this condition "my some other javascript function is not defined", works perfect without condition

Answer: 
Try this :

```
$( "#some-div-container" ).append( 
    "<div>name 1"
    + (
        response == 1 ?    
        "<a href=\"#\">" +
        "<div id=\"add\">Add</div>" +
        "</a>"
        :
        ""
    )
    + "<div>Available</div>" +
        "</div>"
);

```
```
var html;
html += "<div>name 1";
if(response == 1) {    
  html += "<a href=\"#\">";
// other code.....
}                                

 $( "#some-div-container" ).append( html );

```