最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
jquery判断元素是否可见4个例子
时间:2022-06-25 17:44:48 编辑:袖梨 来源:一聚教程网
使用is方法:is(':hidden')例如:
$(document).ready(function(e) {
if($('#d').is(':hidden')){
alert("yes");
}else{
alert("no");
}
});
方法一:
$('#para_div button').click(function() {
if($(this).next().is(":visible")) {
//$(this).html('显示');
$(this).css({"background":"url(/images/btn_arrow_down.png) no-repeat"});
}
else {
//$(this).html('隐藏');
$(this).css({"background":"url(/images/btn_arrow_up.png) no-repeat"});
}
$(this).next().slideToggle('fast');
});
方法二:
$('#para_div button').click(function() {
if($(this).next().css('display') == 'none') {
//$(this).html('隐藏');
$(this).css({"background":"url(/images/btn_arrow_up.png) no-repeat"});
}
else{
//$(this).html('显示');
$(this).css({"background":"url(/images/btn_arrow_down.png) no-repeat"});
}
$(this).next().slideToggle('fast');
});
$('#para_div button').click(function() {
var $cn = $(this).next();
//$(this).html(($cn.is(":visible")) ? '显示' : '隐藏');
(this).css(($cn.is(":visible")) ?
{"background":"url(/themes/HotNewspro/images/btn_arrow_down.png) no-repeat"} :
{"background":"url(/themes/HotNewspro/images/btn_arrow_up.png) no-repeat"});
$cn.toggle('fast');
});
相关文章
- 奔奔王国怎么升阶 建筑英雄宠物升阶方法介绍 12-30
- 奔奔王国怎么找到攻击的人 找到攻击玩家的方法 12-30
- 奔奔王国游戏官网入口在哪 2025年最新官网地址汇总 12-30
- 奔奔王国vip礼包码有哪些 2025年12月vip礼包码汇总 12-30
- 奔奔王国兑换码有什么 2025年12月最新可用兑换码汇总 12-30
- 菜鸡梦想家是什么类型的游戏 游戏类型及核心玩法介绍 12-30