Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
21
rated 0 times [  24] [ 3]  / answers: 1 / hits: 46338  / 15 Years ago, mon, september 14, 2009, 12:00:00

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!


More From » jquery

 Answers
60

This plugin alert()s the ID of each matched element:



jQuery.fn.alertElementId = function()
{
return this.each(function()
{
alert(this.id);
});
};


And to use it:



// alert() each a-element's ID
$(a).click(function ()
{
$(this).alertElementId();
});

[#98702] Wednesday, September 9, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ryder

Total Points: 473
Total Questions: 110
Total Answers: 91

Location: Northern Ireland
Member since Mon, Nov 14, 2022
2 Years ago
ryder questions
Tue, Nov 30, 21, 00:00, 3 Years ago
Fri, Jul 23, 21, 00:00, 3 Years ago
Tue, Jun 15, 21, 00:00, 3 Years ago
Thu, May 20, 21, 00:00, 3 Years ago
;