Javascript 面向iPhone的HTML隐藏
当iphone切换到纵向模式时,有没有办法使用JavaScript隐藏div元素Javascript 面向iPhone的HTML隐藏,javascript,iphone,html,ios,Javascript,Iphone,Html,Ios,当iphone切换到纵向模式时,有没有办法使用JavaScript隐藏div元素 @media all and (orientation:portrait){ #divID { display: none; } } 在CSS中弹出它;-) 你可以做一个lil js“把戏”: 我自己的一本,也许值得一读。 var elem = document.getElementById('elemID'); window.onorientationchange = funct
@media all and (orientation:portrait){
#divID {
display: none;
}
}
在CSS中弹出它;-) 你可以做一个lil js“把戏”:
我自己的一本,也许值得一读。
var elem = document.getElementById('elemID');
window.onorientationchange = function(){
if(document.body.offsetWidth == 960){ //don't remember the best way to retrieve body width atm
elem.style.display = "none";
}else{
elem.style.display = "block";
}
}