这篇文章主要介绍了jquery获得当前html页面源码的方法,涉及jquery针对页面元素的相关操作技巧,具有一定参考借鉴价值,需要的朋友可以参考下:
$("#btnGetCode").click(function(){
var a = '<!DOCTYPE html><html lang="zh-cn">';
var z = "</html>"
var by = $(":root").html();
$("#codeView").val(a+by+z);
});
其中 $(":root") 选择器为根选择器,它总是从<html>开始。