Reputation: 43
What is the best way to detect a mobile device in jQuery?
i found this and i was wondered what the / sign meant in the if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
// some code..
}
code.
Upvotes: 0
Views: 59
Reputation: 341
It's regular expression.
/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)
It returns true if navigator.userAgent
contains the pattern above.
Upvotes: 1