Running a function just before $(document).ready() triggers

前端 未结 3 1384
不知归路
不知归路 2021-02-20 04:02

I\'ve attached multiple functions in multiple files to $(document).ready and would like to attach a single function to happen before them as either the first that $(document).re

3条回答
  •  孤城傲影
    2021-02-20 04:37

    $(document).ready() or simply $(function(){}) is just an .addEventListener implementation (well not exactly, but close), meaning you can add listeners before and after.

    $(document).ready(listener); // goes off first.
    $(document).ready(otherListener); // goes off 2nd.
    

    And so on, it's not hard to sandwich functions. There's no need to hack .ready() imo.

提交回复
热议问题