I have created a javascript function, and I've put in the html code javascipt, but when I make a branching using if else there is an error with the statement "SyntaxError: missing) after argument list" on the sidelines "if" is. following my javascript code.
function tabelListPegawai(data){
return baris = $('<tr>\
<td>'+data.nik+'</td>\
<td>'+data.nama_pegawai+'</td>\
<td>'+data.nama+'</td>\
<td>'+data.nama_jabatan+'</td>\
<td>'if(data.status == 1){'Karyawan Tetap'}else if(data.status == 2){'Karyawan Tidak Tetap'}'</td>\
<td style="text-align: center;">\
<a class="btn btn-small aksi_atas" rel="tooltip" title="Ubah" onclick="editPegawai('+data.id_pegawai+')"><i class="icon-edit"></i></a>\
<a class="btn btn-small aksi_atas" rel="tooltip" title="Hapus" onclick="hapusPegawai('+data.id_pegawai+', '+data.nik+')"><i class="icon-remove"></i></a>\
</td>\
</tr>');
}
Can you help me. thank you
if..elselike that but you can use a ternary operator. Also I'd recommend concatenating your string properly with+for best support across browsers.