I have below the html page.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
alert($("#aaa").html());
});
});
</script>
</head>
<body id="aaa">
<button>hello</button>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<input type="text" name="textt"/>
</body>
</html>
Now on click of hello
button, i need to get raw html content.
It gives below output.
<button>Change content of all p elements</button>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<input name="textt" type="text">
But notice the output. The end tag for input is missing. How can i get exact raw content of html without missing end tag of input
?
I am expecting below output.
<button>Change content of all p elements</button>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<input name="textt" type="text"/>
Thanks!
Try this:
$(document).ready(function(){
$("button").click(function(){
alert($("#aaa").html() +"</input>");
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.