简体   繁体   English

TEXTAREA将html内容分配给值-不显示html标签

[英]TEXTAREA assign html content to value — Not show html tag

I have the html file content and want to assign it to the TEXTAREA value. 我有html文件的内容,并希望将其分配给TEXTAREA值。 But how to not show html tag?? 但是如何不显示 html标签呢?

<TEXTAREA id="Terms"></TEXTAREA>
<script>
$.get("/mobile/en/html/tnc/apply.html", function(tnc) {
   var elem3 = document.getElementById('Terms');
   if (elem3){ elem3.value = tnc; }
});
</script>

apply.html apply.html

<html>
.......
</html>

As it has below function: 由于具有以下功能:

function disableDeclarationCheckbox() {
                var form = document.forms['CardForm'];
                var ta = document.getElementById('Terms');
                if (ta!=null && ta.scrollHeight <= ta.offsetHeight){
                    if (form){ if (form.cardTermsCheckbox){
                        form.cardTermsCheckbox.checked = false;
                        form.cardTermsCheckbox.disabled = false;
                    }}
                    return;
                }
                if (form){ if (form.cardTermsCheckbox){
                    form.cardTermsCheckbox.checked = false;
                    form.cardTermsCheckbox.disabled = true;
                }}
                $('textarea#Terms').on('scroll', function() {
                    if (this.scrollHeight <= (this.scrollTop+this.offsetHeight)) {
                        if (form){ if (form.cardTermsCheckbox){
                            form.cardTermsCheckbox.disabled = false;
                        }}
                    }
                });
                return;
            }

Text areas just show text, they don't interpret HTML. 文本区域仅显示文本,它们不解释HTML。

Instead of a text area, use a div, like this: 使用div代替文本区域,如下所示:

<div id="Terms"></div>
<script>
$.get("/mobile/en/html/tnc/apply.html", function(tnc) {
   var elem3 = document.getElementById('Terms');
   if (elem3){ elem3.innerHTML = tnc; }
});
</script>

If you need users to be able to type into the div, you could change it to 如果您需要用户能够输入div,则可以将其更改为

<div id="Terms" contenteditable="true"></div>

使用<span>代替<textarea>

<span id='Terms'></span>

是否可以设置 a 的 value 属性<textarea><i>tag to be the source code of an html file?</div></i><b>标记为 html 文件的源代码?</div></b></textarea><div id="text_translate"><p> 我想知道是否可以将 <textarea> 标记的值属性设置为网页的 HTML。</p><p> 我试图将值设置为等于本地文件“./file.html”的 HTML。</p><pre> document.getElementById("textareaTag").value =;</pre><p> 由于我是 JavaScript 的新手,所以我没有解决方案,尽管可能有一个。 谁能帮我?</p><p> 注意:一些挖掘使得它看起来可能使用 window.open() 命令来完成此操作。 行得通吗? 如果是这样,如何?</p></div> - Is it possible to set the value property of a <textarea> tag to be the source code of an html file?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将html <a>标签</a>分配<a>给textarea值</a> - Assign html <a> tag to a textarea value 在textarea中输入并不会实际更改HTML标签内容 - Typing in textarea not actually changing HTML tag content HTML - <textarea> 标签困难 - HTML - <textarea> tag difficulties 转义HTML标记<textarea> - Escape HTML tag in <textarea> 获取HTML标记值并分配给PHP变量 - Grab HTML tag value and assign to PHP variable 将字符串变量分配给 html<option value=....>标签 - assign a string variable to html <option value=....> tag 将textarea内容转换为html - Convert textarea content to html HTML textarea显示br - HTML textarea show br 如果通过JQuery提交表单,则HTML标记会自动添加textarea值 - Html tag automatically added textarea value if form submitted through Jquery 是否可以设置 a 的 value 属性<textarea><i>tag to be the source code of an html file?</div></i><b>标记为 html 文件的源代码?</div></b></textarea><div id="text_translate"><p> 我想知道是否可以将 <textarea> 标记的值属性设置为网页的 HTML。</p><p> 我试图将值设置为等于本地文件“./file.html”的 HTML。</p><pre> document.getElementById("textareaTag").value =;</pre><p> 由于我是 JavaScript 的新手,所以我没有解决方案,尽管可能有一个。 谁能帮我?</p><p> 注意:一些挖掘使得它看起来可能使用 window.open() 命令来完成此操作。 行得通吗? 如果是这样,如何?</p></div> - Is it possible to set the value property of a <textarea> tag to be the source code of an html file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM