在放入容器之前是否有可能從AJAX(加載)響應中刪除特定的HTML元素?在這種情況下,我想從響應中刪除「#containerTop」,包括內容。從JQuery AJAX加載()中刪除HTML元素()響應
響應(HTML):
<html>
<head></head>
<body>
<div id="containerMain">
<div>...</div>
<div id="containerTop">Content-to-remove-including-container-div...</div>
</div>
</body>
</html>
我試過這個,沒有成功。
<div id="middle"></div>
<script>
$("#middle").load("http://<URL>",
function(response, status, xhr){
$response.remove('#containerTop');
});
</script>
任何想法?
謝謝,它適用於$( '#中間')HTML(數據).find( '#containerTop')刪除()。但是這會在放置後刪除元素。我可以刪除元素數據放置嗎? – marioa 2014-10-11 22:07:12
@MarioAmmann - 我爲我的答案添加了一個例子。 – jfriend00 2014-10-11 22:14:22
謝謝,這個作品完美。 – marioa 2014-10-14 21:52:58