gpt4 book ai didi

javascript - 对象不支持此属性或方法 'isotope'

转载 作者:行者123 更新时间:2023-11-28 09:49:54 41 4
gpt4 key购买 nike

我的网站出现问题。我在 IE8/9 上遇到网页错误:

Object doesn't support this property or method 'isotope' Line: 47 Char: 3 Code: 0

代码如下:

/*-----------------------------------------------------------------------------------
/*
/* Custom JS
/*
-----------------------------------------------------------------------------------*/

/* Start Document */
jQuery(document).ready(function($) {

/*----------------------------------------------------*/
/* Responsive Menu
/*----------------------------------------------------*/

// Create the dropdown bases
$("<select />").appendTo("#navigation");

// Create default option "Go to..."
$("<option />", {
"selected": "selected",
"value" : "",
"text" : "Menu"
}).appendTo("#navigation select");


// Populate dropdowns with the first menu items
$("#navigation li a").each(function() {
var el = $(this);
$("<option />", {
"value" : el.attr("href"),
"text" : el.text()
}).appendTo("#navigation select");
});


//make responsive dropdown menu actually work
$("#navigation select").change(function() {
window.location = $(this).find("option:selected").val();
});

/*----------------------------------------------------*/
/* Isotope Portfolio Filter
/*----------------------------------------------------*/

$(function() {
var $container = $('#portfolio-wrapper');
// initialize Isotope
$container.isotope({
// options...
resizable: false, // disable normal resizing
// set columnWidth to a percentage of container width
masonry: { columnWidth: $container.width() / 12 }
});

// update columnWidth on window resize
$(window).smartresize(function(){
$container.isotope({
// update columnWidth to a percentage of container width
masonry: { columnWidth: $container.width() / 12 }
});
});


$container.isotope({
itemSelector : '.portfolio-item'
});

var $optionSets = $('#filters .option-set'),
$optionLinks = $optionSets.find('a');

$optionLinks.click(function(){
var $this = $(this);
// don't proceed if already selected
if ( $this.hasClass('selected') ) {
return false;
}
var $optionSet = $this.parents('.option-set');
$optionSet.find('.selected').removeClass('selected');
$this.addClass('selected');

// make option object dynamically, i.e. { filter: '.my-filter-class' }
var options = {},
key = $optionSet.attr('data-option-key'),
value = $this.attr('data-option-value');
// parse 'false' as false boolean
value = value === 'false' ? false : value;
options[ key ] = value;
if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
// changes in layout modes need extra logic
changeLayoutMode( $this, options )
} else {
// otherwise, apply new options
$container.isotope( options );
}

return false;
});
});

/*----------------------------------------------------*/
/* Back To Top Button
/*----------------------------------------------------*/
var pxShow = 300;//height on which the button will show
var fadeInTime = 400;//how slow/fast you want the button to show
var fadeOutTime = 400;//how slow/fast you want the button to hide
var scrollSpeed = 400;//how slow/fast you want the button to scroll to top. can be a value, 'slow', 'normal' or 'fast'

jQuery(window).scroll(function(){
if(jQuery(window).scrollTop() >= pxShow){
jQuery("#backtotop").fadeIn(fadeInTime);
}else{
jQuery("#backtotop").fadeOut(fadeOutTime);
}
});

jQuery('#backtotop a').click(function(){
jQuery('html, body').animate({scrollTop:0}, scrollSpeed);
return false;
});

/* End Document */
})();

出了什么问题?

最佳答案

您需要定义同位素函数。只有这样你才能调用它。我不认为 isotope() 是一个内置函数。

在下面的示例中,我在 h1 元素上添加一个函数 test(),然后调用它。

$('h1')
[<h1>​Hello​</h1>​]

var a = $('h1')

a.test = function() {console.log(this);}

a.test()
[<h1>​Hello</h1>​]

关于javascript - 对象不支持此属性或方法 'isotope',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11206022/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com