jQuery:具有jquery元素的石工(' hide',element)方法 [英] Jquery: masonry('hide',element) method with a jquery element
问题描述
因此,我正在使用Masonry在我的网站中进行流体"布局,但是现在我遇到了涉及其隐藏和显示方法的问题.
So, I'm using Masonry to make a "fluid" layout in my site but now I've encountered a problem involving its hide and reveal methods.
在一种情况下,我正在拨打此电话:
In an event, I'm making this call:
$container.masonry('hide', $(this));
如您所见,我正在使用$(this)
告诉砌体要通过jquery隐藏哪些元素
As you can see, I'm using $(this)
to tell masonry what element to hide through jquery
但是显然,此方法不适用于jquery元素吗?
But apparently, this method does not work with a jquery element?
控制台中的错误消息如下:
The error message in my console looks like this:
Uncaught TypeError: Object #<HTMLElement> has no method 'hide' (masonry.pkgd.min.js:9)
我尝试查看了文档,但有关可接受类型的全部说明是:
I tried looking in the documentation but all it says about the accepted type is:
$container.masonry( 'hide', items )
项目类型: Masonry.Items
Masonry.Item 应该是什么?以及如何将我的元素表示为一个?
What is a Masonry.Item supposed to be? And how do I indicate my element as one?
推荐答案
如果阅读文档,则会发现items
是elements
的array
.
If you read the documentation then you find items
are the array
of elements
.
项目 Type: Array of Masonry.Items
尝试一下,
var arr=new Array();
arr.push($(this));
$container.masonry('hide', arr);
这篇关于jQuery:具有jquery元素的石工(&#39; hide&#39;,element)方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!