I am working on php project. I am uploading some description from textarea to database. Now While I am going to edit the data, I need to add line break at place of br(<br>) tag.
<textarea name="content"></textarea>
<?php $content=$data['content']; ?>
Inside $content variable the description is stored and I want to set it textarea and replacing the br with new line.I want to do this using jquery.
This is very simple. Here I am showing an example.
<script type="text/javascript"> function nl2br (str, is_xhtml) { var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br/>' : '<br>'; return (str + '').replace(/([^>rn]?)(rn|nr|r|n)/g, '$1'+ breakTag +'$2'); } $('textarea[name="content"]').val(nl2br ("<?php echo $content?>")); </script>
Question and answer is powered by AnsPress.io