Alex Rivera | Logout

How to call custom jquery function onClick

Asked 2009-09-14T12:45:14.847
11

Hi. I am new to jQuery.. I want to know how to call custom jQuery function by onClick attribute of HTML. This was the basic I was trying.Further I want to make parametrised function and want to call that function onClick attribute.

my jQuery function is:

jQuery.fn.myFadeIn=function() {
    return $('#fadeInDiv').fadeIn();
};

and the HTML is:

<input type="radio" name="contentCalls" class="radioButton" id="Calls" onclick="myFadeIn();">

<div id="fadeInDiv">
div to open
</div>

Thanks!

Edit
Report

1 Answer

6

Replace:

jQuery.fn.myFadeIn=function() { return $('#fadeInDiv').fadeIn(); };

With:

var myFadeIn=function() { return $('#fadeInDiv').fadeIn(); };

(Assuming you are running this in the global scope)

answered 2009-09-14T12:47:47.313

Your Answer