这个 jQuery 已经在 html 网站上正确测试,现在我需要在 Codeigniter 设置上使用它。
所以我有一个如下所示的 php 页面:
<head>
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/themes/<?php echo $this->config->item("theme"); ?>/normalize.css" type="text/css" />
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/themes/<?php echo $this->config->item("theme"); ?>/component.css" type="text/css" />
<script src="<?php echo base_url(); ?>assets/js/modernizr.custom.js"></script>
</head>
<body>
<div class="container">
<!-- Top Navigation -->
<section class="grid-wrap">
<ul class="grid swipe-right" id="grid">
<li><a href="#"><img src="<?php echo base_url(); ?>assets/css/themes/<?php echo $this->config->item("theme"); ?>/images/dummy.png" alt="dummy"><h3>A fantastic title</h3></a></li>
<!-- etc -->
</ul>
</section>
</div><!-- /container -->
<script src="<?php echo base_url(); ?>assets/js/imagesloaded.pkgd.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/colorfinder-1.1.js"></script>
<script src="<?php echo base_url(); ?>assets/js/masonry.pkgd.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/gridScrollFx.js"></script>
<script src="<?php echo base_url(); ?>assets/js/classie.js"></script>
<script>
new GridScrollFx( document.getElementById( 'grid' ), {
viewportFactor : 0.4
} );
</script>
</body>
</html>
我在控制台上没有任何 Javascript 问题,但是当我向下滚动“GridScrollFx”时,jQuery 不会将“shown”类添加到列表项
GridScrollFx.prototype._scrollPage = function() {
var self = this;
this.items.forEach( function( item ) {
if( !classie.has( item.el, 'shown' ) && !classie.has( item.el, 'animate' ) && inViewport( item.el, self.options.viewportFactor ) ) {
++self.itemsRenderedCount;
if( !item.curtain ) {
classie.add( item.el, 'shown' );
return;
};
classie.add( item.el, 'animate' );
// after animation ends add class shown
var onEndAnimationFn = function( ev ) {
if( support.animations ) {
this.removeEventListener( animEndEventName, onEndAnimationFn );
}
classie.remove( item.el, 'animate' );
classie.add( item.el, 'shown' );
};
if( support.animations ) {
item.curtain.addEventListener( animEndEventName, onEndAnimationFn );
}
else {
onEndAnimationFn();
}
}
});
this.didScroll = false;
}
这是 CSS:
/* Hover effects */
.grid li.shown:hover h3 {
color: #fff;
-webkit-transform: translate3d(0,-30px,0);
transform: translate3d(0,-30px,0);
}
.grid li.shown:hover > a::before {
border-width: 14px;
border-color: #2E3444;
}
.grid li.shown img,
.grid li.shown h3 {
visibility: visible;
}
我的想法来自这个tutorial 。那么为什么向下滚动时不会显示所有已加载的项目?
最佳答案
从您的代码(头部和主体)中,我没有找到任何包含的 jquery js 文件。添加类似这样的内容,
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
关于javascript - 为什么这个 jQuery 在 Codeigniter 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28372327/