0

I have a collapsable tab bar, I wanted it so when I click anywhere on the page it collapses the tabs, I used the code below which works perfect. But, I cant get it to work on touch (iPads, iPhones, etc.)

$(document).click(function(e) {
    // make sure the click is outside the tabs
    if($(e.target).parents('#tabs').length == 0) {
        $('#tabs ul li.ui-state-active a').trigger('click');
    }
});

Any help will be great if someone could tell me exactly how to code it to work with tough also. Thanks

Here is the link of how I got the code to the click and the click on a computer works fine: Collapse jquery tab when click outside of the div

Community
  • 1
  • 1
  • is it the trigger function that is not working..?? – Nibin Feb 03 '15 at 03:44
  • Basically if I'm on a computer I can click and it works, but if I'm on an iPad it wont work I guess because the code is designed for click not touch. I have researched and can see I need to maybe implement 'click touchstart' but I cant figure out how to get it to work with the code in my question – user2969951 Feb 03 '15 at 05:16

1 Answers1

0

Something like this might help u mate.. :)

$(document).on('click touchstart', '#tabs ul li.ui-state-active a',  function(event) {
    event.preventDefault()
    alert('clicked');
});
Nibin
  • 3,922
  • 2
  • 20
  • 38