jQuery html()无法将所有xhtml转换为html标准 [英] Jquery html() cannot convert all xhtml to html standard

查看:101
本文介绍了jQuery html()无法将所有xhtml转换为html标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的网站获取HTML代码.我可以使用html()做到这一点,我需要比较字符串.

I am trying to grab html code from my site. I can do so using html() and I need to compare the string.

例如.

我得到< br/>,但是似乎浏览器或jquery只得到< br>-没有右斜杠.

I get < br/> however it seems the browser or jquery only get < br> - without the closing slash.

我研究并发现了此 http://bugs.jquery.com/ticket/4509

似乎可以通过将页面作为application/xml + xhtml来解决.但是,我无法正常工作.任何专家的建议都表示赞赏.

It seems that it can be resolved by serving the page as application/xml+xhtml. However, I can't get it working. Any expert advice appreciated.

推荐答案

找到了解决方案.对于只想要$(#container").xhtml()之类的任何人,您都可以使用此扩展名. http://code.google.com/p/jqxhtml/

Found a solution. For anyone who want to just something like $("#container").xhtml() , you can just this extension. http://code.google.com/p/jqxhtml/

这是针对IE的,稍加修改即可满足webkit浏览器的要求.希望这可以对将来需要的人有所帮助.

This is for IE, alittle modification of it can caters for webkit browsers as well. Hope this can help anyone who need it in future.

这篇关于jQuery html()无法将所有xhtml转换为html标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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