# Replace DIV if using mobile device

**URL:** <https://forum.kirupa.com/t/replace-div-if-using-mobile-device/328863>\
**Category:** Uncategorized\
**Created:** [June 25, 2012, 9:48pm UTC](https://forum.kirupa.com/t/replace-div-if-using-mobile-device/328863 "2012-06-25T21:48:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![adstudio3d](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@adstudio3d](https://forum.kirupa.com/u/adstudio3d)\
**Post date:** [June 25, 2012, 9:48pm UTC](https://forum.kirupa.com/t/replace-div-if-using-mobile-device/328863/1 "2012-06-25T21:48:33Z")

</div>

I have been searching but can’t find any info… I DON’T want to redirect users to a seperate mobile page, I only want a single div to be replaced if the user is on a mobile device.

Right now I’m just setting the code below on page load. But I need it to be an if statement that if mobile is true then either .replaceWith or set display settings for each div…

```auto

   jQuery('#swapcontentdesktop').replaceWith(jQuery('#swapcontentmobile'));

   $('#swapcontentdesktop').css({ 'display': 'block'});
   $('#swapcontentmobile').css({ 'display': 'none'});

```

Please help :hangover:
