처음으로 클릭 할 때 다른 HTML 페이지를로드하는 버튼이 있습니다. 두 번 클릭하면로드 된 페이지의 div가 비게됩니다.empty() 이후에 DOM 요소가 다시 나타납니다.
그러나,로드 된 내용이 두 번째 클릭 후 다시 나타나지 유지 어떤 이유로 ....
CSS에 대한 :
#boatdiv {
width: 100%;
}
.clicked {}
HTML
<button id="load"></button>
<div id="boatdiv"></div>
jQuery를
$(document).ready(function() {
$.ajaxSetup ({
cache: false
});
var loadURL = "AjaxLoad_injection.html";
$("#load").on("click", function() {
if(!($(this).hasClass("clicked"))){ //checks if button has NOT been clicked
$("#boatdiv").html("<p>loading...</p>").load(loadURL);
}
else {
$("#boatdiv").empty();
}
$("#boatdiv").toggleClass("clicked");
}
);
}); // end ready
무슨 일이야?
아아아. 예! 그것이 문제이다. 고마워요 :) – LazerSharks