', { 'class': 'select-options' }).insertAfter($styledSelect); for (var i = 0; i < numberOfOptions; i++) { $('
', { text: $this.children('option').eq(i).text(), rel: $this.children('option').eq(i).val() }).appendTo($list); } var $listItems = $list.children('li'); $styledSelect.click(function (e) { e.stopPropagation(); $('div.select-styled.active').not(this).each(function () { $(this).removeClass('active').next('ul.select-options').hide(); }); $(this).toggleClass('active').next('ul.select-options').slideToggle(300); }); $listItems.click(function (e) { e.stopPropagation(); $styledSelect.text($(this).text()).removeClass('active'); $this.val($(this).attr('rel')); $list.hide(); }); $(document).click(function () { $styledSelect.removeClass('active'); $list.hide(); }); }) } $('#criticform').on('click', '.btn', function (e) { var data = $('#criticform').serialize(); var timer; $.ajax({ type: 'POST', url: '/become-critic', data: data, beforeSend: function (data) { $('#criticform [type=submit]').prop('disabled', true); }, success: function (data) { $('#responcecontactform').html(''); $('#criticform [type=submit]').prop('disabled', false); if (data.flag == 2) { $('#responcecontactform').html(data.message); timer = setInterval(function () { $('.alert').fadeOut("slow"); clearInterval(timer); }, 4000); return false; } else if (data.flag == 1) { $('#formModal').show(); $('.backdrop').show(); return false; } }, error: function (xhr, str) { } }); return false; }); $('#formModal').on('click', '.close', function () { $('#formModal').hide(); }); });