将样式从div复制到textarea [英] copy styled text from div into textarea
本文介绍了将样式从div复制到textarea的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一些带有html标签的文字 - < pre lang =HTML>< b>第一个文字< / b>& lt; br /& gt;< strong>第二个文字< /强大的>< / pre>
放在div中它看起来像样式但是当我在textarea中通过jquery复制这个html文本时
所有样式都没有在textarea中显示!
plz help asap
解决方案
这是一个解决方案:在textarea中显示HTML [ ^ ]
该帖子中的答案是相关的:
你不能将HTML内容放在文本区域内,因为它是按原样显示的(例如HTML源代码)。 br />
你可以做的是创建一个固定大小的div,并将溢出设置为滚动,例如:
HTML代码:
< style 类型 = text / css >
div.terms
{
width:20em;
身高:15em;
溢出:auto;
}
< / style >
< div class = 条款 >
条款和条件< br / >
< br / >
< br / >
Blah blah .. < img src = / whatever.png alt = blah / >
< / div >
suppose i have some text with html tags - <pre lang="HTML"><b>first text</b><br/><strong>2nd text</strong></pre>
placed in a div and it appears as styled but when i copy this html text in a textarea by jquery
all styles not shown in textarea!
plz help asap
解决方案
Here is a solution: Show HTML in textarea[^]
The answer in that thread that is relevant:
You can''t put HTML content within a text area because it''s displayed as-is (e.g. HTML source).
What you can do is to create a div of a fixed size with the overflow set to scrolling, for example:
HTML Code:
<style type="text/css"> div.terms { width: 20em; height: 15em; overflow: auto; } </style> <div class="terms"> Terms and conditions<br /> <br /> <br /> Blah blah.. <img src="/whatever.png" alt="blah" /> </div>
这篇关于将样式从div复制到textarea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文