How do you call [any] functions in jquery? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How do you call [any] functions in jquery?

I mean like if I have defined a function like this var l; function a(){ l++; } in js I can easy call it in another function by writing a(); but how do you call the same in jquery?

23rd Jul 2017, 5:57 PM
_Retr0/-
_Retr0/- - avatar
8 Answers
+ 10
With the same way...
23rd Jul 2017, 6:03 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 10
$(a=function() { var val = $("p").html(); alert(val); }); a();
23rd Jul 2017, 6:14 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 9
They can, I said it's exactly the same...
23rd Jul 2017, 6:09 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 8
(You shouldn't consider JQuery a different language... It's just an extension of JS.... [A packet of functions...])
23rd Jul 2017, 6:12 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 8
This is an anonymous function... You cannot call it again if it's not assigned to a variable...
23rd Jul 2017, 6:13 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 3
alright that answers my question thanks👍👍👍👍
23rd Jul 2017, 6:14 PM
_Retr0/-
_Retr0/- - avatar
+ 2
but in jquery the functions cannot be given names or can they be given names ? if( answer == true) { need_explanation++; }
23rd Jul 2017, 6:08 PM
_Retr0/-
_Retr0/- - avatar
+ 2
so look at this code given in one of the lesson's $(function() { var val = $("p").html(); alert(val); }); so what is the name of this function and how do I call it in an another function?
23rd Jul 2017, 6:11 PM
_Retr0/-
_Retr0/- - avatar