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
$( "#target" ).click(function() {
alert( "Handler for .click() called." );
});
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
<script>
$(document).ready(function(){
$("#btn-txt").click(function(){
var ptext = $("#my-para").text();
alert(ptext);
});
});
</script>
<button type="button" id="btn-txt">Get Text Content</button>
<p id="my-para">This is a paragraph to Show jQuery text method.</p>
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!');
});