<!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.js"></script> <script> click_span(); function click_span() { $(document).ready(function(e) { var p = document.getElementsByTagName("p")[0]; $(p).hide(3000,"linear",function(){alert("finish")}); }); } </script> </head> <body> <p>p1</p> <span>span</span> <input type="button" value="btn" onclick="click_span()"/> </body> </html>
在完成文档加载后,实现隐藏段落的jquery效果。
如果不加$(document).ready(func);那么在运行document.getElementsByTagName的到空对象,就不能实现文档加载完时隐藏段落的效果
时间: 2024-12-27 10:17:39