jquery - parse JSON null values to get  ? -


i'm parsing json object (from yql) includes null values, this:

 {      "color": "red",      "size": null,      "brand": "nike",  },  {      "color": null,      "size": "xxl",      "brand": "reebok",  },  {      "color": "blue",      "size": "small",      "brand": null,  }, 

i'm using jquery generate markup it:

function (data) {         $("#content").html('<table></table>');         $.each(data.query.results.row, function (i, item) {         $("table")         .append('<tr><td class="color">' + item.color + '</td><td class="size">' + item.size + '</td><td class="brand">' + item.brand + '</td></tr>');         }); 

what can (in jquery ideally) change null's blank space, or @ least put class on td? is:

so rather getting

<td>null</td> 

i either

<td>&nbsp;</td> 

or

<td class="hidethis">null</td> 

you can put inline conditional. equivalent

if( expr. ) {return true} else {return false}  <td class="brand">' + ( item.brand == null ) ? '&nbsp;' : item.brand + '</td></tr>' 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -