<div id='myDiv'>
Line 1.<br />
Line 2<br />
These are <special> characters & must be escaped !@@><></div>
<input type='button' value='click' id='myButton' />
<textarea id='myTextArea'></textarea>
<script>
$(document).ready(function () {
$('#myButton').click(function () {
var text = $('#myDiv').text();
$('#myTextArea').val(text);
});
});
</script>
The aboce Script works in Firefox and Chrome and where asint IE7 its breaking so the code modifies like this,
$('#myButton').click(function () {
var text = $('#myDiv').html().replace(/\<br\>/gi,"\r\n");
$('#myTextArea').val(text);
});
No comments:
Post a Comment