大佬教程收集整理的这篇文章主要介绍了javascript – jQuery.clone()IE问题,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<!DOCTYPE html> <html> <head> <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <meta charset=utf-8 /> <title>JS Bin</title> <!--[if IE]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <script> $(function(){ $('button').click(function(){ var $clone = $('html').clone(); $('#output').text($clone.html()); }); }); </script> <style> article,aside,figure,footer,header,hgroup,menu,nav,section { display: block; } </style> </head> <body> <button>run test</button> <pre id="output"></pre> </body> </html>
有没有知道IE的错误阻止这个,或者我做错了什么?
(我需要克隆它,因为我在输出之前对它进行了一些更改)
$('button').click(function(){ $('#output').empty().html(('<html>\n ' + $('html').html() + '\n</html>') .replace(/&/gm,'&') .replace(/</gm,'<') .replace(/>/gm,'>') .replace(/\r/gm,'') .replace(/\n/gm,'<br>') ); });
这适用于Chrome,Firefox和IE8.
以上是大佬教程为你收集整理的javascript – jQuery.clone()IE问题全部内容,希望文章能够帮你解决javascript – jQuery.clone()IE问题所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。