I wrote this small piece of code to show you better what I mean. Try putting in text with spaces etc, in your code in IE and other browsers. It keeps the formatting (spaces and tabs etc) in Firefox but not in IE.
Code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="jquery-1.3.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#switch").click(function() {
if ($(this).attr("value") == "div") {
$(this).attr("value", "textarea");
$("#mydiv").html($("#mytextarea").val());
$("#mytextarea").val("");
} else {
$(this).attr("value", "div");
$("#mytextarea").val($("#mydiv").html());
$("#mydiv").html("");
}
});
});
</script>
</head>
<body>
<textarea cols="20" rows="20" id="mytextarea" style="width:200px; height:200px"></textarea>
<div id="mydiv" style="width:200px;height:200px"></div>
<input type="submit" value="div" id="switch" />
</body>
</html>
Bookmarks