Currently for a body with HTML: hello</div><p>hai</p><span>Welcome</span>
on alerting $('body').html()
it alerts hello<p>hai</p><span>Welcome</span>
.
But I want it to display hello</div><p>hai</p><span>Welcome</span>
i.e. Alert HTML as it is written within the body.
I can see the exact code when I view the source-code of the page.I really dont know if client-side scripts are capable of displaying the output I asked.
Is it possible ?And if yes How?
If you save your HTML as page. xhtml (instead of page. html ), the browser (Firefox/Chrome or Opera) should find the un-closed tags for you without the need for a validator. Just remember to rename them .
An opening tag begins a section of page content, and a closing tag ends it. For example, to markup a section of text as a paragraph, you would open the paragraph with an opening paragraph tag <p> and close it with a closing paragraph tag </p> (closing tags always proceed the element with a /).
The most common example is the <html> tag, which has both a starting tag and ending tag.
What Is a Void Element? The void elements or singleton tags in HTML don't require a closing tag to be valid. These elements are usually ones that either stand alone on the page or where the end of their contents is obvious from the context of the page itself.
You could make an ajax request, this way the HTML won't be parsed:
$.get(window.location.href,function(data){console.log(data);});
See DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With