Top community members
All Wiki Articles Create Wiki Article

Welcome to Dirask IT community! ❤ 💻
We are community of people that helps each other.

If you think you have some skills to help others

help someone and become a part of our community - List Q & A

JavaScript - how to get outer html?

0 contributions
6 points

Using JavaScript it is possible to get outer html source code in following ways.

1. outerHTML property example

// ONLINE-RUNNER:browser;

<html>
<body>
  <div id="element">
    <h3>Head 1</h3>
    <p>Some apostrophe text...</p>
    <h3>Head 2</h3>
    <p>Some apostrophe text...</p>
  </div>
  <script>

    var element= document.getElementById('element');

    console.log(element.outerHTML);

  </script>
</body>
</html>

2. jQuery example

How to get outerHTML with jQuery has been described in this article.

See also

  1. JavaScript - what is difference between inner and outer html?
  2. jQuery - how to get outer html?

0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more