Best practices for declaring functions inside jquery ready function

前端 未结 3 1622
迷失自我
迷失自我 2020-12-24 06:08

I haven\'t found a good reference for declaring my own functions inside the

jquery.ready(function(){});

I want to declare them so they

3条回答
  •  不思量自难忘°
    2020-12-24 07:06

    It might sound simple but you just ... declare the function. Javascript allows functions to have inner functions.

    $(document).ready( function() {
       alert("hello! document is ready!");
    
       function multiply(a, b) {
           return a * b;
       }
    
       alert("3 times 5 is " + multiply(3, 5));
    });
    

提交回复
热议问题