Try to see if perhaps this sheds a light on your question:
What is the best way to detect a mobile device in jQuery?
As the answer to that thread says, I’d suggest to rely on ‘feature detection’ rather than tablet vs non-tablet (as it may not be as straightforward as one may think) hence –> http://modernizr.com/