tags:

views:

49

answers:

2

Hi,

I am trying to hide an element in my page (it is a youtube player instance). When I use jquery's hide() method, the player gets a bit wonky, in that it stops responding, even after I call .show() again.

Is there another variant on hide(), maybe something like .opacity(0), or .visibility('none') that I can use? I don't mind the player taking up space on the page, I just want to hide it so the user can't interact with it until I'm prepared to show a video (the player happens to require a video to load immediately, but I don't have one until the user selects one from another ui element!)

Thanks

A: 

Try

.css('visiblity', 'collapse');
SLaks
+1  A: 

You could set the element's CSS display property to none, but this is essentially the same as what $.hide() is doing.

Instead of hiding the element containing the video player, consider masking it. Don't modify the visibility of the player element but instead render another element on top and adjust that element's visibility.

Jon Cram
And if that's not possible (depending on what you have on your page), moving the element off-screen often works. I'm not sure about the YouTube player, but I have had problems with Flash video players not completely loading when their `display` is `none`. Moving it offscreen solved my problems in these cases. Try `.css({'position':'absolute','left':'-500px'})` in place of `hide()` and `.css({'position':'inherit','left':'0'})` in place of `show()`
Andrew
How would I render an element on top of it though?
Your video is being rendered within an object or embed element. jQuery will easily tell you the element's position on the page. Use jQuery to append at (almost) any place in your document another element of the same width and height at the same position. If you need more detail, it may be better to ask another question.
Jon Cram