if (this.options.jsonConfig.attributes.length > 0) { var selectswatch = this.element.find('.' + this.options.classes.attributeClass + ' .' + this.options.classes.attributeOptionsWrapper); $.each(selectswatch, function (index, item) { var swatchOption = $(item).find('div.swatch-option').first(); if (swatchOption.length && !$(item).find('div.swatch-option').hasClass('selected')) { swatchOption.trigger('click'); } }); }