hameeda naz hameeda naz -4 years ago 89
jQuery Question

Owl-Carousel: I need to apply rtl: true property only when page load in arabic. Not all the time

In my case, if have site with both languages, english and arabic. When I turn this(rtl:true) property on it reflects in english site as well.
It should be apply when tag have the dir="rtl".

For reference of owl-carosusel
https://owlcarousel2.github.io/OwlCarousel2/demos/rtl.html

Please guide, thanks

Answer Source

As far as I understand this issue below code may help you.

mydir = $("html").attr("dir");

if (mydir == 'rtl') {
     rtlVal=true
}
else{
     rtlVal=false
    }

$('Your ID').owlCarousel({
      rtl: rtlVal
      , loop: true
      , items: 1
      , nav: true
      , dots: false
      , navText: false
});
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download