Why not working innerHTML + include-html?

Viewed 78

sorry my english is bad. but I want to solve this problem. this is html code.

 <body>
<div id="booklist">
    <?php include("../templates/nav.php"); ?>
    <div class="hero">
        <?php include("../templates/aside.php"); ?>
        <main>
        </main>
    </div>
    <?php include("../templates/footer.php"); ?>
</div>
<script src="../dist/bookList_bundle.js"></script>

this is js code. addEventListener works in aside.

import {includeHTML} from "../js/includeHTML";
includeHTML();

document.querySelectorAll('.link').forEach(item => {
item.addEventListener('click', (event) => {
  aside.clickLi(item.textContent);
})

includeHTML is script of https://www.w3schools.com/howto/howto_html_include.asp it is working another file with webpack.

and it is aside class.

class aside{
  clickLi(data){
    const main = document.querySelector("main");

    let sectionName = data;
    main.innerHTML= `<section include-html="./section/${sectionName}.php" class="section"></section>`;
  }
}

i want to use include html source in main tag. but it is not working..

i want to load this html source.

<div>
This is one of sectioNname.
</div>
1 Answers

Try to add static before clickLi function like this: static clickLi(

Related