不确定是否可以在语句中包含$(window).load(function() )?这是正确的吗?
else if (isAndroid){
$('.apple, .bottomcta, .bottomapple, .cta, .cta2').hide();
$('.android').show();
$(window).load(function() {
if ($('.yes2, .YES2').css('display') == 'none') {
$('#bottombadge > p, #badge > p, .bottomandroid, .android, .bottomapple, .apple').remove();
$('#button, .cta, .bottomcta').show();
}
else if ($('.no, .NO').css('display') == 'block') {
$('.bottomapple, .apple').remove();
}
}
);
}有什么想法吗?
发布于 2017-03-30 05:50:12
是的,你能做到。
毕竟,您只是使用jQuery将事件处理程序附加到window对象的load事件。
但是,它不是那么有用,因为@Siphalor评论道:
代码永远不会执行,因为页面应该已经加载好了
相反,您应该这样做:
$(window).load(function() {
if (isAndroid){
$('.apple, .bottomcta, .bottomapple, .cta, .cta2').hide();
$('.android').show();
// more codehttps://stackoverflow.com/questions/43104637
复制相似问题