When you set a counter in a jQuery plugin it will be set per instance of the plugin. For instance
$.myPlugin(\".one\"); $.myPlugin(\".two\"); $.myPlugin = funct
Use custom data- attributes to set a counter
data-
$('button').each(function(){ $(this).attr('data-counter', 0); $(this).click(function () { var counter = parseInt($(this).attr('data-counter')); counter++; console.log(counter); $(this).attr('data-counter', counter); }); });
DEMO