javascript - The onclick remove affecting other button -
i have function delete button (to delete based on click) , working, when clicked on other button delete function not supposed do. how can prevent affecting other button?
function mydelete() { $(document).on('click', '.item', function(){ $(this).remove(); var sum = 0; }); }
you better bind 'click' event particular dom object, rather document object.
please try code :
function mydelete() { $('.item').on('click', function(){ $(this).remove(); var sum = 0; }); }
also, looks weird me have wrap in function. simple wrapper (equivalent of "on dom load") should enough in cases :
$(function(){ // code here such : $('.item').on('click', function(){ $(this).remove(); var sum = 0; }); });
Comments
Post a Comment