I am trying to call a custom function in jquery.
$(document).ready(function() { $('#btnSun').click(function() { myFunction(); }); $.fn.myFunction = function() { alert('hi'); } });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button id="btnSun">Say hello!</button>
I also tried to follow
$(document).ready(function() { $('#btnSun').click(function() { myFunction(); }); }); function myFunction() { alert('hi'); }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button id="btnSun">Say hello!</button>
This does not work! Any idea where I'm wrong?
function jquery user-defined
user269867 Mar 25 '10 at 23:27 2010-03-25 23:27
source share