Imagine a scenario where I need to display a template in two different versions based on the user's device.
For instance, I have utilized the following code:
<div class="desktop">
<body>
Hi Desktop user
</body>
</div>
<div class="mobile">
<body>
Hi mobile
</body>
</div>
While this setup works fine with media queries, I discovered that using JavaScript, $('body')
actually retrieves both objects. Even though the element is hidden due to .desktop
being set to display:none
on mobile devices, it appears that the HTML elements are still rendered. In light of this, would it still be considered good practice to continue implementing this method?