Hi everyone! I am working on a WordPress plugin for embedding videos, and I came across needing to read an iframe’s attributes, before it is displayed anywhere. I searched on many forums, the jQuery documentation, and eventually found that you can create an element without it actually being present in the HTML! It’s frustratingly simple:
var element = $(‘‘);
alert(element.attr(‘src’)); // http://www.youtube.com/embed/QSwilU0kJF0
alert(element.attr(‘height’)); // 315
$() is an object selector, you can also create the object on the spot, without it actually existing in the page! Cool, huh?