I need to use jquery to add some elements on small screens and then remove them on larger screens. But for some reason, .remove() is not removing anything. All my other code is working - just not .remove(). What am I doing wrong?
jQuery(function ($) {
var resizeflag = false;
$(window).resize(function () {
if ($("#wrapper").css("overflow") === "visible") { // sample css to test if media query has fired
if (resizeflag == false) {
resizeflag = true;
// add mobile menu icon
$('#mobile-menu').before('<a id="menu-icon">Menu</a>');
// add Economic Development to header on homepage only
$('#homepage #site-logo').after('<div class="logo-tag">ECONOMIC DEVELOPMENT</div>');
// add footer logo
$('#footer-nav').prepend('<div class="mobile-footer-logo"></div>');
}
} else {
if (resizeflag == true) {
resizeflag = false;
// must undo these DOM manipulations if the browser is expanded again or else it will loop
$("a#menu-icon").remove();
$('div.logo-tag').remove();
$('.mobile-footer-logo').remove();
}
}
}).resize();
});