MiChAeLoKGB MiChAeLoKGB - 6 months ago 10x
Javascript Question

jQuery if iframe with class exists

I am trying to detect if iframe with specific class exists, but its not working for me.

I need to detect if iframe with chat exists on site https://gaming.youtube.com for one of my scripts. Its weird that in this demo it can detect iframe: http://jsfiddle.net/t7qMF/13/ but when you go to any live stream on https://gaming.youtube.com, you can not detect if the iframe with chat exists.

When I use

it returns the iframe, but when I try
I get

I tried googling, but everybody is saying to use
, which is just not working for me. It actually returns undefined even when I just use

Here is screen of my console where its not working:

enter image description here



Because $ is not always jQuery. In Chrome dev console, when jQuery is not available, it is alias to document.querySelector()