Skip to content Skip to sidebar Skip to footer

Change Event Fires Multiple Times

I have this HTML code generating by php code a1

Solution 1:

Everytime you click on $(".edit_tr"), you add another eventhandler, so thats why the code triggers multiple times

Solution 2:

try this code

$(document).ready(function(e) {

    $(".edit_tr").click(function(){
        var id = $(this).attr("id");
        // we have here tow states :#1 and #2 //#1  there is no Id, and thats mean we want to insert to databaseif(typeof id != 'undefined'){
            alert("there is id ");

        }
    });



    $(".edit_tr").find("input").change(function(){
       var stateId = $(this).attr("class");
       var alternativeId = $(this).attr("id");
       alert("state is :"+ stateId);
       alert("alternativeId is :"+ alternativeId);
       //return false;         
   });

});

Post a Comment for "Change Event Fires Multiple Times"