I want to add ID to each element of class .content, and I want each ID to have integer increase by 1. Example:
.content
Try this
var number = 1; $(".content").each(function() { this.id = 'content_' + number++; });
This is iterate single elements one by one rather than taking all elements with .content