.click()
methodThe .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.
.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. |
.click()
method ExampleTrigger the click event on all paragraphs:
$("p").click();
.click([eventData,]handler)
method ExampleHide paragraphs on a page when they are clicked:
$("p").click( function () { $(this).hide(); });