Initialize script

前端 未结 4 1752
灰色年华
灰色年华 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:29

    I figure you're using jquery.ajax to fetch the div?

    If so, you should be able to add the listeners in the success-function of the jquery.ajax call:

    $('#result').load('ajax/test.html', function() {
      $("#result .class").click(function () {
        $(this).toggleClass("add_class");
      });
    });
    

提交回复
热议问题