
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
<script>
function q1() {
fetch("http://spartacodingclub.shop/sparta_api/seoulair").then(res => res.json()).then(data => {
let rows = data['RealtimeCityAir']['row']
$('#names-q1').empty()
rows.forEach((a) => {
let gu_name = a['MSRSTE_NM']
let gu_mise = a['IDEX_MVL']
let temp_html = ``
if (gu_mise > 40) {
temp_html = `<li class="bad">${gu_name} : ${gu_mise}</li>`
} else {
temp_html=`<li>${gu_name} : ${gu_mise}</li>`
}
$('#names-q1').append(temp_html)
})
})
}
</script>
이렇게 funtion 함수를 쓸대 append 함수를 통해서 html처럼 구현을 하는데
let c = [ {'name':'영수', 'age':30}, {'name':'철수', 'age':35} ]
$('#q3').text(c[1]['age'])
바로 위에 있는 예문 같은 경우 append 함수를 이용하지 않고 바로 html에 출력이 되는데 그 이유를 명확히 모르겠습니다.
만약에 위와 id를 참조 이용 여부에 따라 append를 이용하는 경우라면
왜 저희 숙제에서 id를 참조해서 이용하는데도 append를 사용을하지 않는지가 의문입니다.
$(document).ready(function () {
fetch("http://spartacodingclub.shop/sparta_api/weather/seoul").then(res => res.json()).then(data => {
let number = data['temp']
$('#temp').text(number)
})
})
