Tuesday, August 2, 2022
HomeWordPress Developmentjavascript - Append html to div

javascript – Append html to div


I wish to add customized html to a div utilizing this perform within the capabilities.php file. I am unsure why this is not working.

perform add_html_under_div() {
    ?>
        <script kind="textual content/javascript">

          // create a brand new div aspect
          const newDiv = doc.createElement("div");
          newDiv.innerHTML = '<a>check</a>';

          //div
          var description_div = doc.querySelector('.description_div');

          // add newDiv beneath description_div
          description_div.appendChild(newDiv);
        </script>
    <?php
}
add_action('wp_head', 'add_html_under_div');

Am I not getting the description_div the best method?

Any assist is far appriciated!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments