We can call JavaScript or jQuery code when we click on any HTML tag. Without using the onclick attribute of HTML tag we can call the JavaScript or jQuery code.
<script type="text/javascript">
$("HTMLtagName OR .className or #Id").click(function()
{
statements;
});
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button> Click Me For Calling jQuery Click Method ! </button>
<script type="text/javascript">
$("button").click(function()
{
alert('You have clicked the Button');
});
</script>
In above code we have called the an alert() function on button click. We can choose Class and unique specifier ID also.
<script type="text/javascript">
$("button .mybtn").click(function()
{
alert('You have clicked the Button with calss .mybtn ');
});
</script>