评估orientationEvent并设置一个值?
如果发生方向更改时触发 onChange 函数,如何在 onChange 中设置一个值来更新 jquery 选择器。例如:
$(document).ready(function(){
var onChanged = function() {
if(window.orientation == 90 || window.orientation == -90){
image = '<img src="images/land_100.png">';
}else{
image = '<img src="images/port_100.png">';
}
}
$(window).bind(orientationEvent, onChanged).bind('load', onChanged);
$('#bgImage').html(image); //won't update image
});
If I have an onChange function firing when an orientation change has happened, how do I set a value within the onChange that will update a jquery selector. For instance:
$(document).ready(function(){
var onChanged = function() {
if(window.orientation == 90 || window.orientation == -90){
image = '<img src="images/land_100.png">';
}else{
image = '<img src="images/port_100.png">';
}
}
$(window).bind(orientationEvent, onChanged).bind('load', onChanged);
$('#bgImage').html(image); //won't update image
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将对图像的更新放入 onChanged 函数中,以便每次方向更改时,图像 HTML 都会更改。
You need to put the update to the image inside the onChanged function so that every time the orientation changes, the image HTML will be changed.