Search code examples
javascriptjqueryloadselector

How to select new loaded elements in jQuery without any event


I am working on a jQuery project which a part of page is loaded by choosing different options usign load() method. I have this line in my application:

$('.pe').myFunction();

This code must be executed without any event. So I can not use any code like this:
$(document).on('click','.pe',function(){...});

It works well on all preloaded elements with pe class.But it does not work on new loaded contents which have same class.
Can you help me please?


Solution

  • Finally I found the answer. I just put the same code inside the loaded page.

    // New page which will be loaded with its all contents ...
    <script>$('.pe').myFunction();</script>