temp_html(jquary)를 if문에 사용할 시 temp_html을 아래와 같이 빈칸으로 넣어주고, if 문에 결과값을 넣어준다
let temp_html = ``
if (mise > 60) {
temp_html = <li class="bad">${gu_name} : ${mise}</li>
} else {
temp_html = <li>${gu_name} : ${mise}</li>
}
$('#names-q1').append(temp_html);
<script>
function q1() {
$('#names-q1').empty();
$.ajax({
type: "GET",
url: "http://spartacodingclub.shop/sparta_api/seoulair",
data: {},
success: function (response) {
let rows = response['RealtimeCityAir']['row']
for (let i = 0; i < rows.length; i++) {
let gu_name = rows[i]['MSRSTE_NM']
let mise = rows[i]['IDEX_MVL']
let temp_html = ``
if (mise > 60) {
temp_html = `<li class="bad">${gu_name} : ${mise}</li>`
} else {
temp_html = `<li>${gu_name} : ${mise}</li>`
}
$('#names-q1').append(temp_html);
}
}
})