2012-06-15 42 views
0

有没有更好的方法让iPhone手风琴只适用于iPhone?jQuery手风琴仅适用于iPhone

$(document).ready(function() { 
var device = navigator.userAgent.toLowerCase(); 
var ios = device.match(/(iphone|ipod|ipad)/); 
if (ios) { 
    $("#Main_Box_Section .box2:not(:first)").hide(); 
    $("#Main_Box_Section h3").click(function() { 
     $(this).next(".box2").slideToggle("slow").siblings(".box2:visible").slideUp("slow") 
    }) 
} 
}); 

回答

1

Zepto.js摘自:

var ua = navigator.userAgent.toLowerCase(); 

var ipad = ua.match(/(iPad).*OS\s([\d_]+)/); 
var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/); 

if(iphone){ 
    ... 
}