Something like:
<div class="show-on-desktop hide">
Visible on Desktop
</div>
<div class="show-on-mobile hide">
Visible on Mobile
</div>
and then your JS would be:
var windowWidth = $(window).width();
var $desktopVisible = $('.show-on-desktop');
var $mobileVisible = $('.show-on-mobile');
if (windowWidth <= 640) {
$desktopVisible.addClass('hide');
$mobileVisible.removeClass('hide');
} else {
$desktopVisible.removeClass('hide');
$mobileVisible.addClass('hide');
}
CSS:
.hide {display:none;}
Like so?