jQuery检查对象是否隐藏 [英] JQuery check if objects are hidden

查看:56
本文介绍了jQuery检查对象是否隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我有一个问题.我的一个div中有10张图片.图片的名称在第二格中.因此,有10个图像和10个名称.

当用户单击图像时,将隐藏图像以及其各自的名称.因此,如果用户单击第二个图像,它将隐藏其名称,直到所有内容都被隐藏.

用户单击所有图像后,将出现一个警告框.现在请参考代码以获取单个图像:

Hello, I have an issue. I have 10 images in a div. The images'' names are in a second div. So, there are 10 images and 10 names.

When a user will click on an image, it will hide as well as its respective name. So, if the user clicks on the second image, it will hide as well as its name until everything is hidden.

Once the user has clicked all images, an alert box will appear. Refer to the code now for a single image:

$(document).ready (function() {
    $("#image").click(function() {
    $("#image, #name").hide("slow");
    if ($("#image").is(":hidden")) {
    alert("Ok");
    };
    });
});



如您所见,当用户单击图像时,图像将与名称一样隐藏.所有图像都一样.一旦隐藏了图像,便会显示警告框,否则不会显示,因此我必须验证图像是否隐藏.我可以给他们一个类而不是ID,但是用户只能在image div上单击. 请记住,以上示例仅适用于一张图片.我有10张图片,但为了让您理解,决定总体上列举一个示例.图像和名称处于隐藏状态,但未显示警告框!



As you see, when the user will click an image, it will hide as well as well the name. This goes the same for all images. The alert box will be displayed once the image is hidden else not, so I have to verify if the image is hidden. I could give them a single class instead of an ID, but the user can click only on the image div. Bear in mind, the above example is just for one image only. I have 10 images, but decided to include example for one in general to make you understand. The image and the name are hiding, but the alert box is not displayed!

推荐答案

(document).ready(function(){
(document).ready (function() {


(#image").click(function(){
("#image").click(function() {


(#image,#name").hide("slow"); 如果(
("#image, #name").hide("slow"); if (


这篇关于jQuery检查对象是否隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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