[英]Why this jQuery doesn't work in Codeigniter?
此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不會將“顯示”類添加到列表項中
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;
}
我從本教程中學到了這個想法。 那么,為什么向下滾動時未顯示所有已加載的項目?
從您的代碼(頭部和身體),我沒有找到任何包含jQuery js文件。 添加這樣的東西,
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.