Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery wrap an iframe in div

Tags:

jquery

iframe

How would I make jquery wrap an iframe in a div e.g if using a vimeo embed iframe, on load jquery wraps it in a div class:

<div class="iframe"><iframe src="http://player.vimeo.com/video/23358638?title=0&amp;byline=0&amp;portrait=0" width="500" height="300" frameborder="0"></iframe></div>    
like image 534
Hue Avatar asked May 10 '11 08:05

Hue


People also ask

What does the jQuery wrap () function do?

jQuery wrap() method is used to wrap specified HTML elements around each selected element. The wrap () function can accept any string or object that could be passed through the $() factory function. Syntax: $(selector).

Can you use jQuery in an iFrame?

You can use jQuery to add jQuery effects to your iFrame elements, to change the CSS rules, or even to add content. Above, the script is used to change the background color of the . page element within the frame to white.

How do you wrap two divs?

You can use wrapAll() function!

Which jQuery method allows you to add a wrapper element around another set of elements?

The wrap() method wraps specified HTML element(s) around each selected element.


1 Answers

Use jQuery wrap() function :

$("iframe").wrap("<div class='iframe'/>");
like image 98
Sylvain Avatar answered Nov 19 '22 21:11

Sylvain