<%@ page language="java" contenttype="text/html; charset=utf-8"
pageencoding="utf-8"%>
<%
string path= request.getcontextpath();
string basepath=request.getscheme()+"://"+request.getservername()+":"+request.getserverport()+path+"/";
%>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<base href="<%=basepath%>"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<title>生成html</title>
<script type="text/javascript">
$(function(){
alert("!null=="+!null);//true
alert("!undefined=="+!undefined);//true
alert("!false=="+!false);//true
alert("!0=="+!0);//true
alert("!-0=="+!-0);//true
alert("!''=="+!"");//true
debug("调试信息");
ff("风阻了街道");
function debug(msg){
//通过id获取元素
var log=document.getelementbyid("debuglog");
//判断获取到的标签是否存在
alert("1--->"+!log);//true
if(!log){
//元素不存在的情况下,则创建一个
log=document.createelement("div");
log.id="debuglog";
log.innerhtml="<h1>debug log</h1>";
//将创建的div添加到页面中
document.body.appendchild(log);
}
//在找的元素存在的情况下,将msg消息包装在<pre>中。并添加至log中
var pre=document.createelement("pre");
//创建<pre>标签要显示的文本对象
var text=document.createtextnode(msg);
//将<pre>要显示的文本对象添加到<pre>标签中
pre.appendchild(text);
//将<pre>标签添加到<div>中
log.appendchild(pre);
}
//使用jquery进行实现
function ff(msg){
var log=$("#debug");
alert("2--->"+!log);//false,原因是通过jquery获取元素的时候,相当于创建一个jquery对象,即相当于new,!object是false
if(log){
log=$("<div id='debug'></div>");
alert(log);
log.html("<h1>调试信息如下:</h1>");
$("body").append(log);
}
var pre= $("<pre></pre>");
pre.append(msg);
log.append(pre);
}
});
</script>
</head>
<body>
</body>
</html>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号