JQ DOM准备
demo.html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script type="text/javascript"> document.getElementById("panel").onclick=function(){ alert( "元素已经加载完毕 !"); } /*执行错误*/ </script> </head> <body> <div id="panel">click me.</div> </body> </html>
效果图:
demo2.html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> </head> <body> <div id="panel">click me.</div> <script type="text/javascript"> document.getElementById("panel").onclick=function(){ alert( "元素已经加载完毕 !"); } /*正确执行*/ </script> </body> </html>
效果图:
demo3.html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Panel</title> <script type="text/javascript"> window.onload = function(){ document.getElementById("panel").onclick=function(){ alert( "元素已经加载完毕 !"); } } </script> </head> <body> <div id="panel">click me.</div> </body> </html>
效果图:
demo4.html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Panel</title> <script src="js/jquery-1.10.1.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ document.getElementById("panel").onclick=function(){ alert( "元素已经加载完毕 !"); } }) </script> </head> <body> <div id="panel">click me.</div> </body> </html>
效果图:
demo5.html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script type="text/javascript"> function one(){ alert("one"); } function two(){ alert("two"); } window.onload = one ; window.onload = two ; </script> </head> <body> </body> </html>
效果图:
demo6.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="js/jquery-1.10.1.min.js" type="text/javascript"></script> <script type="text/javascript"> function one(){ alert("one"); } function two(){ alert("two"); } $(document).ready(function(){ one(); }) $(document).ready(function(){ two(); }) </script> </head> <body> </body> </html>
效果图:
相关推荐
星星有所不知 2020-10-12
zuncle 2020-09-28
huaoa 2020-09-14
北京老苏 2020-08-17
luvhl 2020-08-17
Kakoola 2020-07-29
drdrsky 2020-07-29
书虫媛 2020-07-08
liaoxuewu 2020-07-08
SIMONDOMAIN 2020-07-08
爱读书的旅行者 2020-07-07
tianzyc 2020-07-04
Vue和React是数据驱动视图,如何有效控制DOM操作?能不能把计算,更多的转移为js计算?因为js执行速度很快。patch函数-->patch,对比tag,对比tag与key,对比children
Lophole 2020-07-04
Lophole 2020-06-28
liaoxuewu 2020-06-26
ApeLife技术 2020-06-26
北京老苏 2020-06-25
Lophole 2020-06-14