728x90
SMALL
#jquery
#click()
.click()
.click() is a property that allows you to perform certain actions when you click on the selected element.
grammar
.click( handler )
For example, if you want a function to run when a button element is clicked, do the following:
$( 'button' ).click( function() {
// function
} );
example
Click on a paragraph to see its borders. Click again to remove the border.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery</title>
<style>
p {
cursor: pointer;
}
.jbBox {
border: 1px solid #bcbcbc;
padding: 20px;
}
</style>
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
$( document ).ready( function() {
$( 'p' ).click( function() {
$( this ).toggleClass( 'jbBox' );
} );
} );
</script>
</head>
<body>
<p>Lorem ipsum dolor.</p>
</body>
</html>
728x90
LIST