The problem is that the input element is created dynamically, namely when you click on an element
<div class="own_btn cursor" id="btn_vacday"> <span> Праздничный день </span> </div> When clicked, this part of jQuery works
$("#btn_vacday").on('click', function () { // Проверка на существование элемента. Если нету, то создаем! if (!$("div").is("#container_vacday")) { $("<div id='container_vacday'></div>").insertAfter("#btn_vacday"); // Отрисуем форму-контейнер design("#container_vacday"); $("<span> Дата праздника </span><br />").appendTo("#container_vacday"); $("<input id='date_vacday' type='text' />").appendTo("#container_vacday"); $("<br /><br /> <textarea id='description_vacday' name='description' placeholder='Описание' />").appendTo("#container_vacday"); $("#description_vacday").css({ height: '75px', width: $("#container_vacday").find("input[id^='date_']").width() + 'px' }); $("<br /><br /><input id='cancel_vacday' type='button' value='Отменить' />").appendTo("#container_vacday"); $("<input id='submit_vacday' type='submit' value='Отправить' />").appendTo("#container_vacday"); There is still no layout. A layout should appear here:
$("div[id^='btn_']").on('click', function () { $("#container_vacday").find("input").each(function() { $(this).inputmask("yyyy-mm-dd"); }); }); But, the problem is that the layout does not fit on the input. Although in each comes. If you hang in some kind of verification alert, then everything works. for example
$("#container_vacday").find("input").each(function() { $(this).on('click', function() { alert('Here'); } }); That displays Here, but right after I click again on
<div class="own_btn cursor" id="btn_vacday"> <span> Праздничный день </span> </div> I connect jquery.inputmask in packages that are offered by NuGet packages.
Thank you in advance for your help. And do not scold much, because I'm just learning
The problem, most likely, is also that for the first time on the click event, it does not see any descendants, and if you click the (div) button again, then something works. But it still does not solve the problem with the mask