切慕溪水 2012-05-01
<!DOCTYPE html>
<html>
<head>
<style>
#div_id_1{color:red};
.div_class_1{color:yellow}
</style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function(){
// 下面几种方法都可以给div赋内容
// $("div").html("111111111111");
// $("div").text("222222222222");
// $("#div_id").html("3333333333");
// $("#div_id").text("4444444444");
// $(".div_class").html("5555555555");
// $(".div_class").text("6666666666");
// alert($("#div_id_1").html());
// alert($(".div_class_1").text());
});
function views(){
$("#div_id_1").show();
// document.getElementById("div_id_1").style.display="";
}
function blanks(){
$("#div_id_1").hide();
// document.getElementById("div_id_1").style.display="none";
}
</script>
</head>
<body>
<div id="div_id" class="div_class"></div>
<div id="div_id_1" class="div_class_1" style="display:none">success forever</div><br>
<input type="button" value="显示" onclick="views();">
<input type="button" value="隐藏" onclick="blanks();"><br>
</body>
</html>
本文实例讲述了jQuery基于闭包实现的显示与隐藏div功能。分享给大家供大家参考,具体如下:。<p>当前手机号码:<span id="oldPhone">$!{user.phone}</span>&