Suppose on one page, I have want to show a template in two version depending on the user's device.
For example, I implemented the following code.
<div class="desktop">
<body>
Hi Desktop user
</body>
</div>
<div class="mobile">
<body>
Hi mobile
</body>
</div>
This works okay with media queries but with javascript, I realized that $('body')
actually returns both objects. Although the user doesn't see the element because .desktop
is set to display:none
on mobile deviecs, it seems that the html elements are rendered. In this case, is it still an okay practice or should I avoid doing something like this?