0

is it possible to remove the class="con" from the DIV, handle it like a "child DIV" from lis and put the content into it?

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>

So it should look like this:

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>
Chama
  • 189
  • 1
  • 3
  • 11

0 Answers0