Use outerHTML
:
var el = document.getElementById( 'foo' );
alert( el.outerHTML );
More Related Contents:
- What is the difference between properties and attributes in HTML?
- How to stop event propagation with inline onclick attribute?
- “Submit is not a function” error in JavaScript
- How can I select an element by name with jQuery?
- What is the most efficient way to create HTML elements using jQuery?
- How to resolve the C:\fakepath?
- How can I simulate a click to an anchor tag?
- Finding line-wraps
- How to get the element clicked (for the whole document)?
- How to avoid the need for ctrl-click in a multi-select box using Javascript?
- How to Implement DOM Data Binding in JavaScript
- Can I load an entire HTML document into a document fragment in Internet Explorer?
- Getting value of HTML Checkbox from onclick/onchange events
- Select all elements with a “data-xxx” attribute without using jQuery
- Get the DOM path of the clicked
- HTML Table with vertical rows
- contentDocument for an iframe
- Remove specific HTML tag with its content from javascript string
- Is it the last `script` element the currently running script?
- How to add DOM element script to head section?
- Get elements from page.evaluate in Puppeteer? [duplicate]
- React, losing saved data in localStorage with useEffect after page refresh
- Getting HTML elements by their attribute names
- How to escape HTML
- User Activity Tracking using javascript library [closed]
- Boolean HTML Attributes
- Is there a way to know if a link/script is still pending or has it failed
- Is there a cross-browser standard on-load event for HTML’s “object” tag?
- How to reduce the length of a video using JavaScript? [closed]
- Why I cant use jQuery functionality