Guest User

Untitled

a guest
Jun 17th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. /* $.ua: iPhone, iPad, iPod detection */
  2.  
  3.  
  4. /**
  5. * $.ua
  6. */
  7. $.ua = (function(){
  8. var o = {};
  9. var ua = navigator.userAgent;
  10. $.each(['iPhone', 'iPod', 'iPad'], function(i, current){
  11. o[current] = Boolean(ua.match(new RegExp(current, 'i')));
  12. o.appleDevice = o.appleDevice || o[current];
  13. });
  14. return o;
  15. })();
  16.  
  17. /**
  18. * test
  19. */
  20. $(function(){
  21. /*
  22. <ul id="test"></ul>
  23. prepare this element and do...
  24. */
  25. $('#test').append(
  26. '<li>iPhone? ' + $.ua.iPhone + '</li>',
  27. '<li>iPod? ' + $.ua.iPod + '</li>',
  28. '<li>iPad? ' + $.ua.iPad + '</li>',
  29. '<li>appleDevice? ' + $.ua.appleDevice + '</li>'
  30. );
  31. });
Add Comment
Please, Sign In to add comment