Skip to content

Instantly share code, notes, and snippets.

@fedmich
Created April 21, 2012 02:50
Show Gist options
  • Save fedmich/2433422 to your computer and use it in GitHub Desktop.
Save fedmich/2433422 to your computer and use it in GitHub Desktop.
Javascript - Hide elements like iframe, embedded objects on the page
/*
Hides iframe from youtube, embedded objects
*/
function hide_other_elements(){
var iframes = document.getElementsByTagName('iframe');
jQuery(iframes).each(function(){
if( (this.src + '').match('http://www.youtube.com/embed/') ){
jQuery( this ).parent().addClass('hidden_elements');
}
});
var objects = document.getElementsByTagName('object');
jQuery(objects).each(function(){
jQuery( this ).parent().addClass('hidden_elements');
});
}
/* add in your CSS */
.hidden_elements{
visibility:hidden;
}
.hidden_elements iframe{
visibility:hidden;
}
/* to restore the hidden objects */
jQuery('.hidden_elements').removeClass('hidden_elements');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment