function runAfterElementExists(jquery_selector, callback) {var checker = window.setInterval(function() {if ($(jquery_selector).length) {clearInterval(checker);callback();}}, 200);} var ArtNr = $('.variationID').html(); $('input[name="variationid"]').val('100566'); $(".ItemQuestionForm form > input[data-mail='subject']").val("Artikel-Nummer: " + ArtNr); $('.ItemQuestionForm input[name="Artikelnr."]').attr('disabled', 'disabled').val(ArtNr); runAfterElementExists('.PlentyArticleCharacters', function() { var item = $('#aromaSelector>li>span'); for (var i = 0; i <= item.length; i++) { if ($(item[i]).text() === $(".PlentyArticleCharacters>.PlentyArticleCharacterName:nth-child(1)").text()) { $(item[i]).addClass('active'); }} for (var i = 0; i <= item.length; i++) { if ($(item[i]).text() === $(".PlentyArticleCharacters>.PlentyArticleCharacterName:nth-child(2)").text()) { $(item[i]).addClass('active'); }} for (var i = 0; i <= item.length; i++) { if ($(item[i]).text() === $(".PlentyArticleCharacters>.PlentyArticleCharacterName:nth-child(3)").text()) { $(item[i]).addClass('active'); }} });