var clubbingLocations = $('#clubbing-locations');
$.getJSON("/js/location.json", function(data) { //load json
for (var i = 1; i <= data.locations.length; i++){ //loop through json, append html and objects
clubbingLocations.append("<div class='night-type location'>" +
"<a href='location.html'>" +
"<div class='overlay'>" +
"<div class='overlay'>" +
"<span class='fav checked glyphicon glyphicon-heart' aria-hidden='true'></span>" +
"<h4>" + data.locations[i].name + "</h4>" +
"<div class='rating-hold'>" +
"</div>" +
"</div>" +
"</a>" +
"</div>"
);
for (var j = 1; j <= data.locations[i].rating; j++){
$('.rating-hold').append("<span class='filled glyphicon glyphicon-star' aria-hidden='true'></span>");
}
}
개체의 리뷰를 각각 rating-hold
에 추가하려고하지만 검토가 누적되어 해당 클래스에 추가하는 대신 서로 겹쳐서 추가됩니다. 첫 번째 평점은 자신을 완벽하게 삽입하지만 그 후에는 서로 자신을 추가하기 시작합니다.각 개체를 '블록'요소에 추가하는 방법은 무엇입니까?
에 아이콘을 포함하여 전체 개체를 추가? –
@ Tha'erAl-Ajlouni 방금 HTML과 객체를 추가하는 '클럽 활동 위치'의 ID를 가진 div가 있습니다. – Rick
아래에서 내 대답을 확인하십시오. 필요한 것을했습니다. –