See what the situation is. The click event is called when you click on an element with a mobil class, but the mobil class appears only when the screen is less than 500px. If you narrow the screen, the mobil class will appear (this is indicated by a red background) but the click event does not occur ... what is the problem? https://jsfiddle.net/rv4gL3c6/2/
$('.mobil').click(function() { $(this).css('background', 'blue'); }); var doit; function resizedw() { if ($(document).width() < 500) { $('.block').addClass("mobil"); } else $('.block').removeClass("mobil"); }; window.onresize = function() { clearTimeout(doit); doit = setTimeout(function() { resizedw(); }, 0); }; .block { height: 100px; background: #000; } .mobil { background: red; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="block"> </div>
mobilelement, and you want it to be applied tomobilE? - smellyshovel