// 'Polyfill' for :placeholder-shown, since it's not standard yet $(document).on('focus focusout', '.zuo-textbox', function(e) { $("label[for='" + $(this).attr('id') + "']").toggleClass('floating', $(this).val() !== ""); }); $(document).on('change.select2', 'select', function(e) { $("label[for='" + $(this).attr('id') + "']").toggleClass('floating', !['', null].includes($(this).val())); });