📌  相关文章
📜  如何使用 jQuery 选择没有可见子元素的元素?

📅  最后修改于: 2022-05-13 01:55:52.900000             🧑  作者: Mango

如何使用 jQuery 选择没有可见子元素的元素?

在本文中,我们将学习如何选择属性不可见或隐藏的元素。它只是意味着该特定元素的显示属性是隐藏的,我们需要使用 Jquery 显示该元素中存在的任何内容。

我们可以通过使用 Jquery:hidden 选择器轻松地做到这一点。首先,让我们看看如何知道元素是隐藏的,这些元素被设置为显示:none; type=”hidden”,宽度和高度设置为 0 或隐藏的父元素的表单元素,该父元素也将隐藏其子元素。

  • jQuery :hidden Selector:这个选择器的任务是选择具有隐藏属性的元素。

句法 -

$(":hidden")
  • jQuery show()方法用于显示被选择器选中的隐藏元素。

句法:

$(selector).show(speed,easing,callback) 
// All parameters are optional.

示例 1:



HTML


  
    
    
  
  
    

GeeksForGeeks

       

It is a computer science portal for geeks.

         

      You can whatever you want to learn in       the computer science field.     

    


HTML


  
    
    
  
  
    

GeeksForGeeks

    

      It is a computer science portal for geeks.     

        

      You can whatever you want to learn in       the computer science field.     

    


输出 :

示例 2:我们有一个带有 display:none 属性的标题标签,其余的标签都是可见的。当您首先运行代码时,它将在 :hidden 选择器和 .show() 方法的帮助下显示可见内容,然后显示隐藏标签。

HTML



  
    
    
  
  
    

GeeksForGeeks

    

      It is a computer science portal for geeks.     

        

      You can whatever you want to learn in       the computer science field.     

    

输出 :