$(window).resize(function() { if($(window).width() < 992) { $('.logo').append($('.logo1')); } else{ $('.logo1').appendTo($('body')); } }); .logo{ background: #ccc; width: 300px; height: 300px; } .logo1{ background: #444; width: 150px; height: 150px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="logo"> </div> <div class="logo1"> </div> When searching the Internet I found a lot of options, I tried, but they all had some kind of crutches or something. I am interested in how to do this in the most correct and universal way for any situation using jquery.