简体   繁体   English

如果textarea是动态的,如何从textarea中删除所有html标签?

[英]How to remove all html tags from textarea if textarea is dynamic?

code: 码:

<script>
    $(document).ready(function(){
        $('#temp').val(function(i,val) {
            return $('<div>').html(val).text();
        });
    });
</script>
<textarea  id="temp"><?php echo $fetch['description']; ?></textarea>

In this code I have a textarea where I am fetching its value from database. 在这段代码中,我有一个textarea,可从数据库中获取其值。 Now, In my database table column it have text with multiple tags like tag P,ul,br and more. 现在,在我的数据库表列中,它的文本带有多个标签,如标签P,ul,br等。 So, How can I remove these tags from textarea ?Please help me. 因此,如何从textarea中删除这些标签?请帮助我。

Thank You 谢谢

我将为此使用PHP函数strip_tags()

<textarea  id="temp"><?php echo strip_tags($fetch['description']); ?></textarea>

下面是具有常规语法的基本函数,请尝试使用该函数string strip_tags(string $ str [,string $ allowable_tags])

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM