Php 在joomla中为sticky div添加jquery时发生冲突
我需要一个标题,粘贴到顶部,同时向下滚动页面。我正在使用以下jquery函数Php 在joomla中为sticky div添加jquery时发生冲突,php,javascript,jquery,Php,Javascript,Jquery,我需要一个标题,粘贴到顶部,同时向下滚动页面。我正在使用以下jquery函数 <script type="text/javascript"> google.load("jquery", "1"); function sticky_relocate() { var window_top = $(window).scrollTop(); var div_top = $('#sticky-anchor').offset().top; if (window_top > d
<script type="text/javascript">
google.load("jquery", "1");
function sticky_relocate() {
var window_top = $(window).scrollTop();
var div_top = $('#sticky-anchor').offset().top;
if (window_top > div_top)
$('#sticky').addClass('stick')
else
$('#sticky').removeClass('stick');
}
// If you have jQuery directly, use the following line, instead
// $(function() {
// If you have jQuery via Google AJAX Libraries
google.setOnLoadCallback(function() {
$(window).scroll(sticky_relocate);
sticky_relocate();
});
</script>
滑块和粘滞div都不工作 让我们看看页面加载后HTMl中的是什么样子的,我猜是因为您已经有了一个滑块,并且正在再次加载jQuery,所以您破坏了滑块。感谢您的评论。如何添加而不破坏滑块?我是php新手,请帮帮我!嗨,阿鲁南,试试这个
;(function($) {
// Whatever code you want that relies on $ as the jQuery object
// End closure
})(jQuery);