如何从textarea转移休息? [英] How to transfer breaks from a textarea ?

查看:59
本文介绍了如何从textarea转移休息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一点点问题。


我将输入字段中的数据传输到div,这样你就可以看到profil

将在您输入数据时显示。

我只是将它放在我的输入字段中:

onkeyup =" document.getElementById (''javao'')。innerHTM L = this.value;"

这个:< span id =" javao">< / spansome在页面上的其他位置。 />

这很好用,我也用textarea做同样的事情。

但是......文本字段中的断点不会转移到div。

我在网上搜索但似乎无法找到任何相关信息。我还用

尝试了使用nl2br的不同解决方案等等,但我无法得到

工作。

所以问题是,如何从textarea传输回车键?

Hi

I have a little probelm.

I tranfer som data from input fields to a div so you can see how a profil
will look as you type in your data.
I just put this in my input field:
onkeyup="document.getElementById(''javao'').innerHTM L=this.value;"
And this : <span id="javao"></spansomewhere else on the page.

This works fine and I also do the same thing with a textarea.
But... The breaks made in the textfield is not tranfered to the div.
I have search the net but can''t seem to find anything about it. I have also
tried different solutions using nl2br and so on, but I just can''t get it to
work.
So the quetion is, how do I transfer the the enter key from a textarea ?

推荐答案

9月12日,9:03 * am,EnjoyNews < mh-nyhe ... @ mail.dkwrote:
On Sep 12, 9:03*am, "EnjoyNews" <mh-nyhe...@mail.dkwrote:




我有一点点问题。 />

我将输入字段中的数据传输到div,这样您就可以在输入数据时看到profil

的外观。

我把它放在我的输入栏中:

onkeyup =" document.getElementById(''javao'')。innerHTM L = this.value;"

这个:< span id =" javao">< / spansome页面上的其他地方。


这很好用,我也用textarea做同样的事情。

但是......文本区域中的中断不会转移到div。

我在网上搜索但似乎找不到任何关于它的信息。我还用

尝试了使用nl2br的不同解决方案等等,但是我无法得到

工作。


所以问题是,如何从textarea传输回车键?
Hi

I have a little probelm.

I tranfer som data from input fields to a div so you can see how a profil
will look as you type in your data.
I just put this in my input field:
onkeyup="document.getElementById(''javao'').innerHTM L=this.value;"
And this : <span id="javao"></spansomewhere else on the page.

This works fine and I also do the same thing with a textarea.
But... The breaks made in the textfield is not tranfered to the div.
I have search the net but can''t seem to find anything about it. I have also
tried different solutions using nl2br and so on, but I just can''t get it to
work.

So the quetion is, how do I transfer the the enter key from a textarea ?



你需要用tex />
< br替换textarea中的所有< cr>< lf [text end-of-line] / [HTML end-of-line]

You need to replace all <cr><lf[text end-of-line] in textarea with
<br/[HTML end-of-line]




" GArlington" < ga ******** @ tiscali.co.ukskrev i en meddelelse

news:11 ******************* *************** @ e53g2000 hsa.googlegroups.com ...

9月12日上午9:03,EnjoyNews < mh-nyhe ... @ mail.dkwrote:

"GArlington" <ga********@tiscali.co.ukskrev i en meddelelse
news:11**********************************@e53g2000 hsa.googlegroups.com...
On Sep 12, 9:03 am, "EnjoyNews" <mh-nyhe...@mail.dkwrote:




我有一点点问题。 />

我将输入字段中的数据传输到div,这样您就可以在输入数据时看到profil

的外观。

我把它放在我的输入栏中:

onkeyup =" document.getElementById(''javao'')。innerHTM L = this.value;"

这个:< span id =" javao">< / spansome页面上的其他地方。


这很好用,我也用textarea做同样的事情。

但是......文本区域中的中断不会转移到div。

我在网上搜索但似乎找不到任何关于它的信息。我有



尝试使用nl2br的不同解决方案等等,但我无法得到它



work。


所以问题是,如何从textarea传输回车键?
Hi

I have a little probelm.

I tranfer som data from input fields to a div so you can see how a profil
will look as you type in your data.
I just put this in my input field:
onkeyup="document.getElementById(''javao'').innerHTM L=this.value;"
And this : <span id="javao"></spansomewhere else on the page.

This works fine and I also do the same thing with a textarea.
But... The breaks made in the textfield is not tranfered to the div.
I have search the net but can''t seem to find anything about it. I have
also
tried different solutions using nl2br and so on, but I just can''t get it
to
work.

So the quetion is, how do I transfer the the enter key from a textarea ?



你需要用tex />
< br替换textarea中的所有< cr>< lf [text end-of-line] / [HTML end-of-line]


ok ...所以换行符实际上是< cr>< lfin a textarea?

但是如何在javascript中运行时替换它?

You need to replace all <cr><lf[text end-of-line] in textarea with
<br/[HTML end-of-line]

ok... so the line breaks is actually <cr><lfin a textarea ?
But how do I replace this on the run in javascript ?


On Fri,2008年9月12日11:21:11 +0200,EnjoyNews < mh ******** @ mail.dkwrote

in< 48 *********************** @ dtext02.news.tele.dk> :
On Fri, 12 Sep 2008 11:21:11 +0200, "EnjoyNews" <mh********@mail.dkwrote
in <48***********************@dtext02.news.tele.dk> :

>
ok ...所以换行符实际上是< cr>< lfin a textarea?
但是怎么做我在javascript上运行时替换它了吗?
>
ok... so the line breaks is actually <cr><lfin a textarea ?
But how do I replace this on the run in javascript ?



这类东西 -


函数clean(asd){

asd = asd.replace(/ \r / g,"")//在IE和Opera中使用'supress''返回''

asd = asd。替换(/ \ n / g,唱歌)//新行 - 空格或< br}


(是的,可以内联为

newstring = oldstring.replace(/ \ r / g,"")。replace(/ \ n / g,sing)


where sing ="< br> ;或< p>"(记得添加< / palso)


您可能需要担心标签(\t)和额外空格以及多个

''输入'

Something of this sort --

function clean(asd) {
asd=asd.replace(/\r/g,"") //supress ''returns'' used in IE and Opera
asd=asd.replace(/\n/g,sing) //new line --space or <br }

(yes, can be inline as
newstring=oldstring.replace(/\r/g,"").replace(/\n/g,sing)

where sing = "<br>" or "<p>" (remember to add the </palso)

You might want to worry about tabs (\t) and extra spaces and multiple
''enter''s


这篇关于如何从textarea转移休息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆