I have a text displayed from database and I create a "Edit Text" button to edit it and save it. It works when the text from database is in one line but if I use an enter to text for going to the new line it doesn't work at all.
I remove the getting text from database part for easier testing that:
<?php
$rr="asdadsasd \n d";
?>
<form method="post" action="">
<input type="submit" id="edp"value="EditPst">
<div class="post"id="pst"><?php echo nl2br($rr);?></div>
</form>
<script>
$(document).on("click", "#edp", function() {
$("#edp").replaceWith('');
$("#pst").replaceWith('<textarea name="pps" class="post"id="pss"><?php echo nl2br($rr);?></textarea><input type="submit" id="spp" value="save"name="svpst"><input type="submit" id="canp" value="cansel">');
});
</script>
If you remove the \n
part it works fine.
tags?](https://stackoverflow.com/questions/784539/how-do-i-replace-all-line-breaks-in-a-string-with-br-tags) – Twisty Jan 05 '20 at 22:33
when i click on edit text , in the edit text show the
element – 11111111111111111 Jan 05 '20 at 22:43