How to call function in jquery

In jquery you can call a function using Html Events, using attributes like name, id, class

By event

<button onclick="Jqfunction()">By Event</button>

<script>
function Jqfunction() {
   alert('Jquery function');
}
</script>

By Class

<button class="byclass">By Class</button>

<script>
$('.byclass').click(function(){
   alert('By class');
});
</script>

By Id

<button id="byid">By Id</button>

<script>
$('#byid').click(function(){
   alert('By Id');
});
</script>

By Name

<button name="byname">By Name</button>

<script>
$('button[name="byname"]').click(function(){
   alert('By Name');
});
</script>

Related Sourcecode

More Sourcecode

×
Google login
SignUp with Email
X