Reputation: 722
i wanted to do something after a JQUERY have successfully run,
var Public = $("a[data-tooltip-content*='Public']").closest(classes).css({"background-color": "yellow"});
if($(this).is(Public)){
CountPub = CountPub + 1;
console.log(CountPub);
}
1) invoke a element with the colour yellow if the selector is correct
2) increase the counter by 1 everytime it has successfully invoked the css scripts
Upvotes: 0
Views: 55
Reputation: 171698
This might be all you need, just counting the number of elements that match the selector by using length
of resultant collection
var Public = $("a[data-tooltip-content*='Public']").closest(classes).css({"background-color": "yellow"});
var CountPub = Public.length
Upvotes: 2
Reputation: 28584
It seems that you want to do this:
var CountPub = 0;
$("a[data-tooltip-content*='Public']").closest(classes).each(function(i, el) {
$(el).css('background-color', 'yellow');
CountPub++;
});
Upvotes: 1