JQuery显示和影藏DIV

本文介绍了如何使用JQuery核心库将DOM元素转化为JQuery对象,并通过一个简单的示例展示了如何利用JQuery操作DOM元素实现元素的显示与隐藏。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[b]<!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=gbk" />
<title>StripingTable</title>
<script type="text/javascript" src="http://www.wozaishuo.com.cn/example/jquery/jquery-1.2.1.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function(){ });

//隐藏和显示div层
function changeDisplay(){
var helloDivObj = $("#helloDiv");
var buttonObj = $("#btnDisplay");
var val = buttonObj.attr("value");
if(val=="隐藏"){
helloDivObj.hide();
buttonObj.attr("value","显示");
}else{
helloDivObj.show();
buttonObj.attr("value","隐藏");
}
// var helloDivObj = $("#helloDiv").toggle(); //甚至只需要这一句搞定切换隐藏与显示
}
-->
</script>
</head>
<body>
<div class="title_a">一、JQuery核心库</div>
<div class="title_b">(一)、jQuery(e-xpression,[context])用法!</div>
<div class="title_c">3.jQuery(elements)</div>
将一个或多个DOM元素转化为jQuery对象。这个函数也可以接收XML文档和Window对象(虽然它们不是DOM元素)作为有效的参数。<p></p>

<input id="btnDisplay" type="button" value="隐藏" onclick="changeDisplay()"/>
<div id="helloDiv">
Hello,everyone<p></p>
Hello,everytwo<p></p>
Hello,everythree<p></p>
</div>
</bdoy>
</html> [/b]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值