我有一个div数组,我们将调用一个索引进行过滤
Resturant.menus
有三个不同的菜单
以下内容将返回索引
的已配置display
值
console.log(Resturant.menus[0].style.display)
但是,在应用以下内容时,这不起作用并在style
上抛出和未定义的异常:
console.log(Resturant.menus.filter("." + index).style.display)
我在调试器中注意到,仅仅应用console.log(Resturant.menus.filter("." + index)
选择div本身而不是包含所有属性的对象时,看起来我在使用filter
时的级别为高。在使用style
?
filter
答案 0 :(得分:1)
jQuery // The public method that is accessed by class.push<std::vector<int>>(12);
template<class T>
void push(T data) {
push(tag<T>(), data);
}
// The private method that calls the actual vector push for vector types
template<class T>
void push(tag<std::vector<T>>, std::vector<T> const& data_vector) {
push_vector(data_vector);
}
// The actual implementation
template<class T>
void push_vector(std::vector<T> const& data_vector) {
// Actual implementation in here
}
返回一个jQuery对象。 jQuery集合是所选元素的包装器。 filter
是DOM元素的属性,即它是style
对象的属性。要使用该属性,您首先应使用HTMLElement
方法或括号表示法.get(index)
从集合中获取元素:
[index]
您还可以使用Resturant.menus.filter("." + index).get(0).style.display;
Resturant.menus.filter("." + index)[0].style.display;
方法返回集合中第一个元素的指定属性:
prop
因为你想使用Resturant.menus.filter("." + index).prop('style').display;
方法获得一个CSS属性更有意义:
css