-1
    //next.php//////////////////////////////////////////////
    <script>
    $(document).ready(function(e) {
        $('a').click(function(){
            $.get('/next.php', function(data){
                $('#container').append(data);
            });
        });

         $('.btn').click(function(){
             alert();
         });
    });
    </script>

    <a>GET</a>
    <div id="container"></div>

    //next.php//////////////////////////////////////////////
    <input type="button" class="btn" />

I have a page use $.get and append the data from another page. my problem is in my first page, i have script .btn click - alert();

its not working from those button get from another page.

Ben
  • 2,562
  • 8
  • 37
  • 62
  • possible duplicate of [jQuery - Click event doesn't work on dynamically generated elements](http://stackoverflow.com/questions/6658752/jquery-click-event-doesnt-work-on-dynamically-generated-elements) – Ram Jan 26 '14 at 04:11

1 Answers1

1

Setting an event using $.on or aliases like $.click only sets them for elements currently on the page. Use delegate to set events for current and future elements. More info: http://api.jquery.com/delegate/

$("body").delegate(".btn", "click", function(){
         alert();