English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The click() method triggers a click event, or attach a function to be executed when the click event occurs.
A click event occurs when a user clicks on an element.
Trigger the click event of the selected element:
$.click()
Attach a function to the click event:
$.click(function)
Trigger the click event of the <p> element:
$(document).ready(function(){ $("p").click(); });Test and see‹/›
Attach a function to the click event (a click event will occur when the user clicks on an element):
$("p").click(function(){ $(this).css({"background-"color":"#007FFF", "color":"white"}); });Test and see‹/›
Hide the paragraph on the page when the paragraph is clicked:
$("p").click(function(){ $(this).slideUp(); });Test and see‹/›
Attach the 'named' feature to the click event:
$(document).ready(function(){ $("p").click(changeSize); }); function changeSize() { $(this).animate({fontSize: "+=5px}); }Test and see‹/›
Parameters | Description |
---|---|
function | Function executed when a click event is triggered |