Initialize script

前端 未结 4 1753
灰色年华
灰色年华 2021-01-25 10:01

I need to learn how to initialize scripts. I have google it but dont dont really understand it.

Right now I have a toggle-script that is in a div, that entire div gets l

4条回答
  •  粉色の甜心
    2021-01-25 10:40

    You should put this script inside a document.ready call.

    Eg.

    $(document).ready(function() {
        //Put your code here
    });
    

    If I misunderstood your question and what you actually mean is:

    How do you execute the script after you load it in through an AJAX call. Then see this question: executing script after jQuery Ajax Call

提交回复
热议问题