xxxxxxxxxx
$("p").click(function(){
alert("The paragraph was clicked.");
});
xxxxxxxxxx
$( "#target" ).click(function() {
alert( "Handler for .click() called." );
});
xxxxxxxxxx
//1st way
$(".searchCategory").click(function () {
//your code here
});
//2nd way
$(".searchCategory").on( "click",getCategory); // getCategory is a function but don't need the pharenthesis
//if you write getCategory() instead of getCategory when getCategory is a function with no pharamenters it might not work
xxxxxxxxxx
// Wait for the document to be fully loaded
$(document).ready(function() {
// Find the button element using its id or class
var button = $('#buttonId'); // Replace buttonId with the actual id of your button
// Attach a click event handler to the button
button.click(function() {
// Code to be executed when the button is clicked
console.log('Button clicked!');
// Additional code can be added here to perform specific actions
});
});
xxxxxxxxxx
// Select the button using its ID or class
const button = $('#buttonId'); // Replace 'buttonId' with the actual ID or class of the button
// Attach a click event handler to the button
button.on('click', function() {
// Your code to execute when the button is clicked
console.log('Button clicked!');
});
xxxxxxxxxx
1
2
3
$( "#dataTable tbody" ).on( "click", "tr", function() {
console.log( $( this ).text() );
});
xxxxxxxxxx
$(document).on('click touch', '.your-element', function () { });