Hi,
Code below works fine up to hr. For some reason, html code appears as is in textarea. It should first appear as notmal text. Anyone know why?
Thanks
<!DOCTYPE html>
<html>
<head>
<style>
p { margin:8px; font-size:20px; color:blue;
cursor:pointer; }
b { text-decoration:underline; }
button { cursor:pointer; }
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<p>
<b>Click</b> to change the <span id="tag">html</span>
</p>
<p>
to a <span id="text">text</span> node.
</p>
<p>
This <button name="nada">button</button> does nothing.
</p>
<br />
<hr />
<div>Now click me to turn plain text into html code in textarea below.</div>
<br />
<textarea rows="3" cols="20"><b>Bold</b></textarea>
<script>
$("p").click(function () {
var htmlStr = $(this).html();
$(this).text(htmlStr);
});
$("div").click(function () {
var htmlStr = $('textarea').html();
$('textarea').text(htmlStr);
});
</script>
</body>
</html>