jQuery Tutorial Tutorials - jQuery .click() method

jQuery .click() method

The .click() method in jQuery is used to bind an event handler to the click event on the element
or trigger an click event on an element.

jQuery .click() method Syntax

.click()
.click(handler)
.click(eventData,handler)

.click(handler) and .click(eventData,handler) are shortcut for .on( "click", handler )

.click() is shortcut for .trigger( "click" )

Parameter Type Description
handler Function A function to execute when the click is triggered on the matched element.
eventData Anything Additional data passed to the event handler.

jQuery .click() method Example

example

Trigger the click event on all paragraphs:

$("p").click();

jQuery .click([eventData,]handler) method Example

example

Hide paragraphs on a page when they are clicked:

$("p").click( function () { $(this).hide(); });

Try now

Date:2019-08-29 23:57:06 From:www.Lautturi.com author:Lautturi