简体   繁体   English

JS仅在刷新页面后才能工作

[英]JS only works after refreshing the page

I have 3 columns that extend to equal height 我有3列延伸到相等高度

and this is the JS that makes those 3 columns work: SEE DEMO 这是使这3列起作用的JS: SEE DEMO

<script>
  $(document).foundation();
</script> 
<script>
   if(!(/iPhone|iPad|iPod|Android|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent) )) {
jQuery(document).ready(function($){
    var inHeight = $("#wrapper").innerHeight();
    $("#wrapper .col").each(function(){
        $(this).height(inHeight+"px");
        $(this).find('.content').height((inHeight-60)+"px");
    });
}); 
}
</script>

The problem is that this only works when I refresh the page. 问题是,这仅在刷新页面时有效。 Sometimes I even need to refresh the page a couple of times to make it work. 有时,我什至需要刷新页面几次才能使其正常工作。 Is there any way to fix this issue? 有什么办法可以解决此问题? Thanks! 谢谢!

This is my JS structure: 这是我的JS结构:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
<script src="js/modernizr.js"></script>
<script src="js/foundation.min.js"></script> 
<script>
  $(document).foundation();
</script> 
<script>
   if(!(/iPhone|iPad|iPod|Android|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent) )) {
jQuery(document).ready(function($){
    var inHeight = $("#wrapper").innerHeight();
    $("#wrapper .col").each(function(){
        $(this).height(inHeight+"px");
        $(this).find('.content').height((inHeight-60)+"px");
    });
}); 
}
</script> 
jQuery(document).ready(function ($) {
    if(!(/iPhone|iPad|iPod|Android|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))) {
        var inHeight = $("#wrapper").innerHeight();
        $("#wrapper .col").each(function () {
            $(this).height(inHeight + "px");
            $(this).find('.content').height((inHeight - 60) + "px");
        });
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM