是否可以从DIV中删除 class =" con" ,将其处理为" child DIV"来自 lis 并将内容放入其中?
HTML:
<div class="lis" id="123">Title...<div class="con"></div></div>
JAVASCRIPT:
<script>
[].forEach.call(document.getElementsByClassName("lis"), function(elem) {
elem.addEventListener("click", function() {
// get data via ajax
this.getElementsByClassName("con")[0].innerHTML = data;
});
})
</script>
所以看起来应该是这样的:
HTML:
<div class="lis" id="123">Title...<div></div></div>
JAVASCRIPT:
<script>
[].forEach.call(document.getElementsByClassName("lis"), function(elem) {
elem.addEventListener("click", function() {
// get data via ajax
// put the data into the child of this.id / lis DIV
});
})
</script>