jquery的toggle实现文字隐藏与显示

来源:岁月联盟 编辑:exp 时间:2012-03-28
//toggle实现文字的显示与隐藏 
<!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 type="text/javascript" language="javascript" src="../../jquery-1.7.1.min.js"> 
</script> 
<script language="javascript"> 
$(document).ready(function(){ 
    $("#btn1").toggle(function(){ 
             
            $("p").hide("slow"); 
            },function(){ 
                $("p").show("slow"); 
                 
         
        }); 
         
    }); 
 
</script> 
</head> 
 
<body> 
<p style="background:#3F3">this is pi<br> 
this is pi<br> 
this is pi<br> 
this is pi<br> 
this is pi<br> 
this is pi<br> 
</p> 
<input type="button" value="显示/隐藏" id="btn1"> 
</body> 
</html>   

摘自  席伟娜的专栏