How to call a Jquery function starting with $ from outside a javascript function -
i have jquery function below
var func = $(function add(){ });
i have below js code phone call function
function rest(){ //try 1 var fun = new func(); fun.add(); //try 2 add(); }
but both of times getting errors only. how phone call them properly
the problem add
isn't callable function. it's function gets called when dom ready. it's shorthand $(document).ready(fn)
fn
add
in case.
one way can declare within callback instead.
$(function(){ function add(){...} function rest(){...} });
this avoids spawning globals bad practice. if you're calling them elements, consider binding event handlers.
javascript jquery
No comments:
Post a Comment