Jack
Jack

Reputation: 37

Function not work after alert

I have function to renumbering list, on list i have delete button which call confirmation alert, after alert function renumbering not work

This my script

<script type="text/javascript">
    $(document).ready(function(){

        numbering()
    });
    function numbering(){
        .....
    }

    $('#deletebtn, #addbtn').on('click', function(){
        numbering();
    });
</script>

Can anyone suggest me whats wrong with my script, thanks.

Upvotes: 0

Views: 66

Answers (1)

Rajaprabhu Aravindasamy
Rajaprabhu Aravindasamy

Reputation: 67187

Try to wrap the event binding inside of document ready,

$(document).ready(function(){
   numbering();
   $('#deletebtn, #addbtn').on('click', numbering);
});

function numbering(){
    ..... 
}

Or if you want to put it outside the ready handler for sure, then you need to go with event-delegation

Upvotes: 1

Related Questions