I have a form with a textbox like this:
<html>
<head>
<script type="text/javascript" src="jquery-1.6.2.js"></script>
</head>
<body>
<input type="text" id="myTextBox" />
</body>
</html>
When I type something in myTextBox, the value is available with $("#myTextBox").val()
, but is not represented if i do $("body").html()
. How can I grab the html string and the updated form value too? Thanks!
You can use the .attr()
function.
Example:
$("input").each(function(){
$(this).attr("value", $(this).val());
});
After this you can do the:
$("body").html();
This should work.
$('[type=text], textarea').each(function(){ this.defaultValue = this.value; });
$('[type=checkbox], [type=radio]').each(function(){ this.defaultChecked = this.checked; });
$('select option').each(function(){ this.defaultSelected = this.selected; });
then
$("body").html()
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