textarea標簽換行符以br存入數據庫 ,br轉 textArea換行符


textArea換行符轉 <br/>

textarea標簽回車符是/n,在html里識別回車是<br/>,在存入數據庫之前要進行轉換成<br/>,在取出展示在html頁面時才能顯示換行。

<tr>
            <td align=right width="20%" height="100">備注:</td>
            <td><textarea name="beiz" id="beiz"  class="textarea" style="width:80%;height:80px;"></textarea></td>
</tr>

在提交前存入數據庫前轉換一下

<script lanuage="javascript">
        var descrip = $("#beiz").val();
        descrip=descrip.replace(/\n/g,'<br />');
        $("#beiz").val(descrip);
</script>

這樣存進數據庫就是<br/>

<br/> 轉 textArea換行符

span_html = $("#test_span").html()
"測試<br>測試<br>測試<br>測試<br>"
text_area = $("#222");
n.fn.init [textarea#222, context: document, selector: "#222"]
text_area.val();
""
text_area.val(span_html.replace(/<br>/g,"\n"))
n.fn.init [textarea#222, context: document, selector: "#222"]

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM