Reputation: 89
I want all the code inside an pre-tag but innerHTML or jquery : html() doesnt return all the code. Some things where cut off. Like doctype und head body tags etc.
<pre id="pre">
<!DOCTYPE html>
<html >
<head></head>
<body>
<div>asdfds</div>
</body>
</html>
</pre>
When i alert the innerHTML of the #pre object it only alerts the div
http://jsfiddle.net/6o8xjtaq/1/
Is there any other possibility to solve this?
Upvotes: 1
Views: 1164
Reputation: 589
If you really want to do it, use a script
<script id="pre" type="text/template">
<!DOCTYPE html>
<html >
<head></head>
<body>
<div>asdfds</div>
</body>
</html>
</script>
$('#pre').text();
Upvotes: 2
Reputation: 59232
Replace <
and >
with <
and >
so you can get it as wanted, yet not invalid html.
<pre id="pre">
<!DOCTYPE html>
<html >
<head></head>
<body>
<div>asdfds</div>
</body>
</html>
</pre>
Upvotes: 2