I have a script that automatically adjusts the width of child divs based on the number of children. On smaller screens, I want them to be 100% wide. I've attempted inserting the script within the existing code for regular screens as well as at the end of the page, but neither method worked.
Check out the code snippet below:
$(".basecollections").each(function(){
var child_width = 100 / $(this).children().length;
child_width = Math.floor(child_width);
$(this).children().css("width", child_width + "%");
if (screen.width < 1000) {
$(this).children().css('width', '100%');
}
})