📜  jQuery UI |标签

📅  最后修改于: 2021-11-25 04:10:16             🧑  作者: Mango

标签用于在网页上创建可以交换的多个部分,就像手风琴一样。它有助于对内容进行分组并一次查看来自特定组的内容。

标签是通过遵循特定的标记创建的,如下所示:

  • 标签应该包含在有序列表或无序列表中
  • 每个选项卡标题都应该单独包装在一个列表项和一个锚定标签中,并用一个 href 属性来指定每个选项卡面板的内容
  • 每个选项卡面板都可以是空的,但它应该有自己的 id,对应于在关联选项卡的锚元素中输入的散列名称。

选项卡面板中的内容可以在同一页面上定义,也可以通过 Ajax 加载,两者都由与该面板的锚标记关联的 href 属性处理。
下面我们使用 jquery UI 为一个简单的 4 面板选项卡编写代码。

选项卡在带有 id 的 div 标签中指定。在jquery代码中指定了它的id。在这里,我们选择了第二个选项卡作为默认选项卡,将在网页打开时选择该选项卡。您可以通过在活动选项中指定不同的值来更改它。
注意:标签从“0”开始索引。

下面的示例说明了 jQuery 选项卡:
示例 1:此示例代码是一个简单的 jquery 选项卡,所有选项卡都是可评估的。

  • 程序:
    
      
    
        
    
        
    
        
        
        
            
                     
    • Algorithms
    •             
    • Data Structure
    •             
    • Practice
    •             
    • interview
    •                            GeeksforGeeks         
               
                

                    The answer to this is simple, we can have all the                  above things only if we have performance. So                  performance is like currency through which we can                 buy all the above things. Another reason                  for studying performance is – speed is fun!             

            
               
                

                    For example, let us say, we want to store marks of                  all students in a class, we can use an array to store                 them. This helps in reducing the use of number of                  variables as we don’t need to create a separate                  variable for marks of every subject.  All marks can                 be accessed by simply traversing the array.             

            
                  
                

                    Asymptotic Analysis is the big idea that handles                  above issues in analyzing algorithms. In Asymptotic                 Analysis, we evaluate the performance of an algorithm                 in terms of input size (we don’t measure the actual                  running time). We calculate, how does the time                  (or space) taken by an algorithm increases with                  the input size.             

                 
               
                

                    Also, in Asymptotic analysis, we always talk about                  input sizes larger than a constant value. It might                  be possible that those large inputs are never given                 to your software and an algorithm  which is                  asymptotically slower, always performs better for                  your particular situation. So, you may end up choosing                 an algorithm that is Asymptotically slower but faster                  for your software.             

            
           
                        
  • 输出:

示例2:保持所有标签默认关闭,您也可以选择保持所有标签默认关闭。为此,我们使用Collapsible选项并将其值设置为“True”,并将active选项的值设置为 false。

  • 程序:
    
      
    
        
    
        
    
        
        
        
            
                     
    • Algorithms
    •             
    • Data Structure
    •             
    • Practice
    •             
    • interview
    •                            GeeksforGeeks         
               
                

                    The answer to this is simple, we can have all the                  above things only if we have performance. So                  performance is like currency through which we can                 buy all the above things. Another reason                  for studying performance is – speed is fun!             

            
               
                

                    For example, let us say, we want to store marks of                  all students in a class, we can use an array to store                 them. This helps in reducing the use of number of                  variables as we don’t need to create a separate                  variable for marks of every subject.  All marks can                 be accessed by simply traversing the array.             

            
                  
                

                    Asymptotic Analysis is the big idea that handles                  above issues in analyzing algorithms. In Asymptotic                 Analysis, we evaluate the performance of an algorithm                 in terms of input size (we don’t measure the actual                  running time). We calculate, how does the time                  (or space) taken by an algorithm increases with                  the input size.             

                 
               
                

                    Also, in Asymptotic analysis, we always talk about                  input sizes larger than a constant value. It might                  be possible that those large inputs are never given                 to your software and an algorithm  which is                  asymptotically slower, always performs better for                  your particular situation. So, you may end up choosing                 an algorithm that is Asymptotically slower but faster                  for your software.             

            
           
                        
  • 输出:

示例 3:在本示例中,我们将禁用选项卡。我们可以使用禁用选项选择禁用特定选项卡或所有选项卡。首先,我们禁用所有为禁用选项设置值“True”的选项卡。

  • 程序:
    
      
    
        
    
        
    
        
        
        
            
                     
    • Algorithms
    •             
    • Data Structure
    •             
    • Practice
    •             
    • interview
    •                            GeeksforGeeks         
               
                

                    The answer to this is simple, we can have all the                  above things only if we have performance. So                  performance is like currency through which we can                 buy all the above things. Another reason                  for studying performance is – speed is fun!             

            
               
                

                    For example, let us say, we want to store marks of                  all students in a class, we can use an array to store                 them. This helps in reducing the use of number of                  variables as we don’t need to create a separate                  variable for marks of every subject.  All marks can                 be accessed by simply traversing the array.             

            
                  
                

                    Asymptotic Analysis is the big idea that handles                  above issues in analyzing algorithms. In Asymptotic                 Analysis, we evaluate the performance of an algorithm                 in terms of input size (we don’t measure the actual                  running time). We calculate, how does the time                  (or space) taken by an algorithm increases with                  the input size.             

                 
               
                

                    Also, in Asymptotic analysis, we always talk about                  input sizes larger than a constant value. It might                  be possible that those large inputs are never given                 to your software and an algorithm  which is                  asymptotically slower, always performs better for                  your particular situation. So, you may end up choosing                 an algorithm that is Asymptotically slower but faster                  for your software.             

            
              
                                          
  • 输出:

示例 4:在此示例中,我们将禁用某些特定选项卡。在下面的代码中,我们禁用了第 1 个和第 3 个选项卡(就索引而言是第 0 和第 2 个):

  • 程序:
    
      
    
        
    
        
    
        
        
        
            
                     
    • Algorithms
    •             
    • Data Structure
    •             
    • Practice
    •             
    • interview
    •                            GeeksforGeeks         
               
                

                    The answer to this is simple, we can have all the                  above things only if we have performance. So                  performance is like currency through which we can                 buy all the above things. Another reason                  for studying performance is – speed is fun!             

            
               
                

                    For example, let us say, we want to store marks of                  all students in a class, we can use an array to store                 them. This helps in reducing the use of number of                  variables as we don’t need to create a separate                  variable for marks of every subject.  All marks can                 be accessed by simply traversing the array.             

            
                  
                

                    Asymptotic Analysis is the big idea that handles                  above issues in analyzing algorithms. In Asymptotic                 Analysis, we evaluate the performance of an algorithm                 in terms of input size (we don’t measure the actual                  running time). We calculate, how does the time                  (or space) taken by an algorithm increases with                  the input size.             

                 
               
                

                    Also, in Asymptotic analysis, we always talk about                  input sizes larger than a constant value. It might                  be possible that those large inputs are never given                 to your software and an algorithm  which is                  asymptotically slower, always performs better for                  your particular situation. So, you may end up choosing                 an algorithm that is Asymptotically slower but faster                  for your software.             

            
              
                                          
  • 输出:

示例 5:我们可以选择默认打开哪个元素,默认情况下鼠标点击事件打开选项卡,我们也将其更改为鼠标悬停以打开或激活该选项卡

  • 程序:
    
    
        
    
        
    
        
        
        
            
                     
    • Algorithms
    •             
    • Data Structure
    •             
    • Practice
    •             
    • interview
    •                            GeeksforGeeks         
               
                

                    The answer to this is simple, we can have all the                  above things only if we have performance. So                  performance is like currency through which we can                 buy all the above things. Another reason                  for studying performance is – speed is fun!             

            
               
                

                    For example, let us say, we want to store marks of                  all students in a class, we can use an array to store                 them. This helps in reducing the use of number of                  variables as we don’t need to create a separate                  variable for marks of every subject.  All marks can                 be accessed by simply traversing the array.             

            
                  
                

                    Asymptotic Analysis is the big idea that handles                  above issues in analyzing algorithms. In Asymptotic                 Analysis, we evaluate the performance of an algorithm                 in terms of input size (we don’t measure the actual                  running time). We calculate, how does the time                  (or space) taken by an algorithm increases with                  the input size.             

                 
               
                

                    Also, in Asymptotic analysis, we always talk about                  input sizes larger than a constant value. It might                  be possible that those large inputs are never given                 to your software and an algorithm  which is                  asymptotically slower, always performs better for                  your particular situation. So, you may end up choosing                 an algorithm that is Asymptotically slower but faster                  for your software.             

            
           
                                          
  • 输出:

示例 6:在此示例中,我们将根据该选项卡的内容更改选项卡页面高度。为此,我们需要尽可能短地定义最小高度。以及根据内容增加标签页高度的溢出属性。

    程序:
  • 
    
        
    
        
    
        
        
        
            
                     
    • Algorithms
    •             
    • Data Structure
    •             
    • Practice
    •             
    • interview
    •                            GeeksforGeeks         
               
                

                    The answer to this is simple, we can have all the                  above things only if we have performance. So                  performance is like currency through which we can                 buy all the above things. Another reason                  for studying performance is – speed is fun!             

            
               
                

                    For example, let us say, we want to store marks of                  all students in a class, we can use an array to store                 them. This helps in reducing the use of number of                  variables as we don’t need to create a separate                  variable for marks of every subject.  All marks can                 be accessed by simply traversing the array.             

            
                  
                

                    Asymptotic Analysis is the big idea that handles                  above issues in analyzing algorithms. In Asymptotic                 Analysis, we evaluate the performance of an algorithm                 in terms of input size (we don’t measure the actual                  running time). We calculate, how does the time                  (or space) taken by an algorithm increases with                  the input size.             

                 
               
                

                    Also, in Asymptotic analysis, we always talk about                  input sizes larger than a constant value. It might                  be possible that those large inputs are never given                 to your software and an algorithm  which is                  asymptotically slower, always performs better for                  your particular situation. So, you may end up choosing                 an algorithm that is Asymptotically slower but faster                  for your software.             

            
           
                                          
  • 输出: