I am using the code snippet below within the body of a WordPress page, that is built using the page builder Elementor. I am using a tabs element and I am trying to make sure that the first tab is open on 768px and up but closed on 768px and below. The script below closes the tab element perfectly, but it closes all the time, how can I make sure that it only works at 768px and below?
<script>
jQuery(document).ready(function($) {
var delay = 10; setTimeout(function() {
$('.elementor-tab-title').removeClass('elementor-active');
$('.elementor-tab-content').css('display', 'none'); }, delay);
});
</script>
3
Answers
Returns width of browser viewport
$( window ).width();
so you do like that:
You can calculate the the viewport width:
const vw = jQuery(window).width();
Then,
At Elementor you can get the device type ("mobile", "tablet", "desktop") by a data attribute of the body with:
jQuery( 'body' ).data( 'elementor-device-mode' )