您好我正在尝试将append()
个HTML
个元素添加到动态创建的div
这里是我的页面结构
HTML:
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<div id="main-wrapper">
<div id="container">
<div id="left-column">
<div id="filter-cont">Filtered</div>
</div>
<div id="right-column">
</div>
</div>
</div>
</body>
</html>
我正在使用AJAX
调用来创建#container
和#left-colum
,它已创建并且我还有要追加的元素,但问题是我无法选择#left-colum
。这是我到目前为止尝试过的JQuery
代码
JQuery:
<script>
//Ajax calling function
function display_data() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
$("#main-wrapper #left-column").append(xhr.responseText);
//$("#left-column").append(xhr.responseText); Not working as well
if(html_string != ''){
$("#filter-cont").css("display", "block");
}else{
$("#filter-cont").css("display", "none");
}
} else {
alert('There was a problem with the request.');
}
}
}
</script>