There is a function in which when loading the script I go over everything
$("#groups input[type=button]") // где input созданны динамически How can I find a dynamically created element using jQuery ?! I have done this before, only then were click or change events.
And I need to bust without any action from the user, immediately at boot.
The fact is that my function should work when the page is loaded and resize:
$(function () { //... AdaptiveFilter(); // здесь НЕ работает поиск динамических элементов $(window).resize(function() { AdaptiveFilter(); // здесь работает поиск д.э }); //... }); function AdaptiveFilter() { if ($(window).width() > 750) { var rowWidth = $("#groups").width(); var countItems = Math.floor(rowWidth / (200 + 5)); var inputOrder = -1; var detailsOrder = 0; $("#groups input[type='button']").each(function() { if (($(this).index()/2) % countItems == 0) { inputOrder += 2; } else { inputOrder++; } $(this).css("order", inputOrder); }); $(".details").each(function() { if((($(this).index()-1)/2) % countItems == 0) { detailsOrder += countItems + 1; } $(this).css("order", detailsOrder); }); $(".details").width(countItems * 200); } else { $(".filterCategory").children().each(function() { $(this).css("order", 0); }); $(".details").width("100%"); } }