I’m iterating through a variable called content, it contains several HTMLLIElement objects.
How can i use jQuery’s or JavaScript’s functions with this object?, what I’m trying to do is the kind of validation written in the commented code.
$.each(content, function(index, value){
//if(!value.is(':hidden')){
console.log(index + ' : ' + value);
//}
});
What I’m getting is
Uncaught TypeError: Object # has no method ‘is’
If I do value.getAttribute('style'); I get 'display: none;'
The second parameter in your
$.eachfunction references a DOMHTMLLIElementelement. To apply a jQuery method such asisto it you have to wrap yourvalueelement inside a jQuery object:Fiddle.
As noted by @anonymousdownvotingislame,
if($(value).is(':visible'))may be more readable as the human brain tends to have difficulty interpreting double negations, let alone you don’t have to use the not!operator. Thanks.=]