It’s a swiss-army knife. i.

 
Lundblad: Szychowski: what’s so funny?

Zampieri: Thanks Ihm I will do that now.

Szychowski: Ignore me. i’ve been having a rough time lately and just find it interesting when people provide descriptions of code instead of just making a fiddle.

Lachenauer: But it improves psychic powers!

Ihm: Https://jsfiddle.net/7ar1w87f/

Szychowski: Heh, i wish i was home drunk.

Ihm: There’s always that one guy.

Esbensen: Maybe better phrasing would’ve been: i wish i got paid for this thing im doing

Pabst: Trying out headless drupal

Ow: Better play QuakeWorld

Delacerda: Is there any way to see if there is any visible content inside a div?

Barbo: The div always has a bunch of iframes and other divs

Moallankamp: If it’s blank I want to remove it

Carollo: As in nothing visible inside the div

Ihm: Lol visible can be different things

Ihm: It could be hidden in which case it’s not visible

Ihm: Or it could be off screen

Ihm: What are you referring to

Vinti: There’s no display:none;

Binney: But inside there is no visual content

Szychowski: I mean, you could .filter children i guess?

Szychowski: But it really depends.

Kanelos: It’s difficult to explain

Wiggens: Basically I’m playing around with these ad codes

Rencher: Sometimes when there’s no ad displayed

Szychowski: You have an empty container?

Szychowski: You could’va just started with that. plenty of us have experience with those kinds of things :

Mcthige: In those cases I want to hide the div as it’s useless to have an empty box

Szychowski: Are you specifying a height on those containers?

Szychowski: Becauce you shouldn’t need to.

Goldberger: It’s easy, leave the div at the ads fixed size and add some tearjerker adblock text as background

Bibbs: Decx: that’s one way haha

Rival: Not sure how much that’ll help though

Szychowski: Also: you won’t be able to know if/when the ad loaded.

Bastarache: No not sure how to do that

Wolsky: Earlier I used to check for iframe, img and object

Szychowski: But you can’t know if the load has already happened or not.

Oliverio: The ad code is always fully loaded when the script runs

Beaudin: So it’s always fully loaded when I run the script checking the ad div

Szychowski: But the iframe contents may not be.

Szychowski: Buuut what to i know ;

Shattuck: Iframes are bit tricky indeed as you can’t access the contents inside or know when they’re loaded

Szychowski: Well, that’s not entirely accurate, but yeah basically.

Szychowski: You don’t know when the iframe itself has been injected, etc.

Lavery: But luckily I’ve noticed that they’re either set to display:none or have their heights and widths set to 0 when they’re empty

Wenk: Alright, found a simple solution

Youngstrom: If$’#adContainer’.children’:visible’.length == 0 { console.log”no ad”; }

Szychowski: 2 things – never use ==, and 0 is falsy, so you can just do if !$’#adContainer’.children’:visible’.length { console.log”no ad”; }

Klaiber: You’re definitely right about that

Matsushita: Took the code from here

Kelderman: Http://stackoverflow.com/a/10382439

Szychowski: Right, very similar to what i suggested a while ago.

Hartert: Haven’t used filter before so not very familiar with the function

Szychowski: It’s a swiss-army knife. i usually ignore selectors like :visible becuase they can be very slow.