.click()
StevenSwiniarski466 total contributions
Published Aug 4, 2022Updated Aug 4, 2022
Contribute to Docs
The .click()
method attaches an event handler to the "click"
event of an HTML element.
Syntax
$(selector).click(handler);
A handler
function will be assigned to the "click"
event of the HTML element(s) specified by selector
.
Example
The following jQuery code will spawn a message box every time a paragraph in the document is clicked:
$("p").click(function() {alert("Paragraph clicked!");});
All contributors
- StevenSwiniarski466 total contributions
- BrandonDusch580 total contributions
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.