📜  jQuery | one() 与示例

📅  最后修改于: 2021-11-25 03:41:27             🧑  作者: Mango

one() 方法是 jQuery 中的一种内置方法,可为所选元素附加一个或多个事件处理程序。这还附加了一个在事件发生时运行的函数。此方法命名为 one,因为附加到此方法的任何事件处理程序都将只运行一次。

句法:

$(selector).one(event, data, function)

参数:此方法接受上面提到的三个参数,如下所述:

  • 事件:它是必需的参数。它用于指定要附加到元素的一个或多个事件。如果给出多个事件,则使用空格将它们分开。
  • 数据:它是可选参数。它用于指定要传递给函数的附加数据。
  • 函数:它是必需的参数。它用于指定事件发生时要运行的函数。

返回值:此方法返回具有指定事件处理程序的选定元素。

程序:



    
        
        
        
    
       
    
        
            
GeeksforGeeks
            
A computer science portal for geeks
            

Prepare for the Recruitment drive of product based             companies like Microsoft, Amazon, Adobe etc with a free             online placement preparation course. The course focuses             on various MCQ's & Coding question likely to be asked              in the interviews & make your upcoming placement season             efficient and successful.

            

An extensive Online Test Series for GATE 2019 to boost             the preparation for GATE 2019 aspirants. Test series is             designed considering the pattern of previous years GATE             papers and ensures to resemble with the standard of GATE.             This Test Series will help the aspirants track and improve             the preparation through questions of various difficulty             levels.

        
    

输出:
段落大小修饰符
段落大小修饰符