PHP IF条件:
-> <?php if($pet['pet_type'] == 'Lost'){echo $pet['pet_name'];}else{echo 'Please Help Me';}?>
JS IF:
<h3 class="title" style="word-break: break-all;">'+if(res[i].pet_type === 2){res[i].pet_name}else{+'Please help me'+}+'</h3>
请帮助我哪里出错了。我怎样才能解决这个错误?
答案 0 :(得分:1)
您需要concatenate
正确
var concat = '';
concat = '<h3 class="title" style="word-break: break-all;">';
//if(res[i].pet_type === 2){
if(2 === 2) {
//value = res[i].pet_name;
value = 'sssss';
}
else {
value = 'Please help me';
}
concat+= value+'</h3>';
console.log(concat);
&#13;