textarea的值并处理回车换行的方法
$(document).keypress(function(e){ if (e.ctrlKey && e.which == 13 || e.which == 10 || e.which == 13) { e.preventDefault();//屏蔽enter对系统作用。按后增加\n等换行 } });
原理:textarea中的回车是用\n代替,html中是用<br/>代替的
所以在提交的时候需要将\n转换成 <br/>
存:
bsBulletin.Content = bsBulletin.Content.Replace("\n", "<br/>");
取:
//处理换行问题 var content = '@Model.Content'.replace(/<br\/>/g, "\n"); document.getElementById("Content").value = content;
编辑:孙小北
本文地址: https://www.xiaowangyun.com/wyblog/detail/?id=179
版权归属: www.xiaowangyun.com 转载时请以链接形式注明出处
0 条评论