you can check if the element has select2
attribute
$('.MyDripdowns').each(function (i, obj) {
if (!$(obj).data('select2'))
{
$(obj).select2({ width: "455px" });
}
});
EDIT
As @Fr0zenFyr said in his comment for v4.0 you can use :
if (!$(obj).hasClass("select2-hidden-accessible"))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…