Jquery HTML方法 [英] Jquery HTML Method

查看:82
本文介绍了Jquery HTML方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JQuery来处理一个项目,并且在使用html()方法时遇到了一些麻烦。有什么方法可以忽略文本中的某些标签?例如,如果字符串是

 段落可以以< code>< p>< code>标签

我怎样才能让代码标签被解释,但是带有标签的p标签括号不会?如果解决方案需要Jquery以外的东西,请告诉我。



提前致谢!

解决方案

试试这个:使用符号& lt; & lt; /& gt; 来关闭这样的标签。
示例:
段落可以以< p>教程< / p>标记开始

& lt; < & gr; > 。将它们结合起来将创建一个括号作为标签,而不会被浏览器解释为html标签。



奖励: DEMO 。易于使用。


I'm using JQuery to work on a project and am having some trouble with the html() method. Is there any way that the method can ignore certain tags in the text? For example if the string is

"A paragraph can be started with a <code><p><code> tag"

How can I make it so that the code tag will be interpreted but the p tag with it's brackets will not? If the solution requires something beside Jquery, still let me know.

Thanks in advance!

解决方案

Try this:

Use symbol &lt; and &lt;/ &gt; for closing tag like this. Example : "A paragraph can be started with a <p> Tutorial </p> tag"

&lt; is < , &gr; is >. Combining both of them will create a bracket as tag that will not interpreted by browser as a html tag.

Bonus: DEMO. Easy to use.

这篇关于Jquery HTML方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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