Jump to content

how to make code work on desktop only

Recommended Posts

 how can I make this code...:

<script      src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
  $(document).ready(function() { 
        $('section.ProductItem-additional').insertAfter('.ProductItem-details-excerpt');
    });
</script>
<style>
  section.ProductItem-summary {
    align-items: flex-start !important;
}
  section.ProductItem-additional {
    margin-top: 20px !important;
    margin-bottom: 20px !important;
}
</style>

 

...work on desktop only

Link to comment
  • 1 month later...

@tuanphan Would you be able to help me solve this if i post a link to my SquareSpace site, please?

I'm using exactly the same jquery that was posted above, but need to restrict this from working on Mobile devices. I have the MemberSpace plugin active, but you can view the current code on the below credentials:

Whttps://www.sbd-vox.com/dewalt-nordic/p/mp97509-qz/mp97510-qz
U: help@code.com
P: Password8   (Where the first letter is the only capital)

Thank you in advance for any help you can provide!

Link to comment
On 10/13/2022 at 3:54 PM, DPaskalot said:

@tuanphan Would you be able to help me solve this if i post a link to my SquareSpace site, please?

I'm using exactly the same jquery that was posted above, but need to restrict this from working on Mobile devices. I have the MemberSpace plugin active, but you can view the current code on the below credentials:

Whttps://www.sbd-vox.com/dewalt-nordic/p/mp97509-qz/mp97510-qz
U: help@code.com
P: Password8   (Where the first letter is the only capital)

Thank you in advance for any help you can provide!

Change this

 $(document).ready(function() { 
        $('section.ProductItem-additional').insertAfter('.ProductItem-details-excerpt');
    });

to this

 $(document).ready(function() { 
if ($(window).width() <= 767) {
        $('section.ProductItem-additional').insertAfter('.ProductItem-details-excerpt');
                            }
    });

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 4 weeks later...

Hi Tuanphan,

Managed to get the code working but spotted an error in your code, where the "<" and "=" symbols were the wrong way round (With the correct code below). Posting this in case it helps anyone in the future

Thank you for your help @tuanphan! Much appreciated

On 10/16/2022 at 3:33 AM, tuanphan said:
$(document).ready(function() { 
if ($(window).width() >= 767) {
        $('section.ProductItem-additional').insertAfter('.ProductItem-details-excerpt');
                            }
    });

 

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.