1
현재 javascript, html 및 css를 사용하여 웹 페이지를 디자인하고 있습니다. 이 페이지는 사용자가 좌석을 선택하거나 선택을 취소 할 수있는 좌석 예약 좌석입니다. 사용자가 시트를 선택했을 때 시트의 ID를 표시하도록 페이지를 가져 왔지만 사용자가 시트를 선택 취소하면 디스플레이에서 ID를 제거하는 데 문제가 있습니다.요소 추가 및 제거
다음은 DOM 요소가 아닌 속성에 자바 스크립트 코드
$('.available, .unavailable, .selected').click(function(){
var ID = $(this).attr('class');
if (ID == 'n unavailable' || ID == 'p unavailable') {
alert ('Seat is already booked. Please select another seat.');
}
else if (ID == 'n selected' || ID == 'p selected') {
alert ('You have now unselected this seat.');
$(this).html('<img src = "free.gif"/>');
$(this).removeClass('selected').addClass('available');
y--;
$("#seats").html("Number of seats selected: " + y);
$("#list").remove($(this).attr('id'));
}
else {
alert ('You have now reserved this seat. You can unselect it by clicking the seat again.');
$(this).html('<img src = "selected.gif"/>');
$(this).removeClass('available').addClass('selected');
y++;
$("#seats").html("Number of seats selected: " + y);
$("#list").append($(this).attr('id') + "</br>");
}
});
는'$ 무엇입니까 ('#list')'? 선택한 좌석의 ID를 표시하는 'div'또는 'span'입니까? – Marcus