如何使用jQuery将div CSS的可见性更改为可见 [英] How to change visibility of a div css to visible with jQuery

查看:121
本文介绍了如何使用jQuery将div CSS的可见性更改为可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的屏幕上有NEXT和PREVIOUS按钮.最初加载页面时,我希望隐藏上一步"按钮,并且当用户单击下一个"按钮时,我希望上一个"按钮(div标记可见).我有一个CSS属性用于上一步"按钮,其中将可见性值设置为False. 还有一条if语句,我在该语句中检查页计数器是否大于1,然后将navigationButtonTop的可见性更改为true.它不起作用..我在做什么错!!

I have NEXT and PREVIOUS buttons on my screen. When the page initially loads I want the Previous button to be hidden and as soon as user clicks the Next button I want Previous button (div tag to be visible). I have a CSS property for Previous button where I am setting the visibility value to False. And also an if statement where I check to see if page counter is greater than 1 then change the visibility of navigationButtonTop to true. It is not working..what am I doing wrong !?

$(function() {
  $("#navigationButtonTop").css("visibility", "visible");
});

div.navigationButtonTop {
  visibility: hidden;
  height: 100px;
  width: 100px;
  background-color:blue;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="navigationButtonTop"></div>

推荐答案

首先,您尚未关闭if语句,并且navigationButtonTop是不是id的类,请尝试此操作.

firstly you have not closed your if statement and navigationButtonTop is a class not a id try this.

if (that.get("pageCounter") >= 1) {
     $(".navigationButtonTop").css("visibility", "visible");
}

OP修改了他的问题后,新的答案将是:

as the OP has edited his question the new answer would be:

$(function() {
  $(".navigationButtonTop").css("visibility", "visible");
});

这篇关于如何使用jQuery将div CSS的可见性更改为可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆