Reputation: 9661
I have an image
<div class='container'>
<img src='../images.jpg' alt='images' />
</div>
I want to put this image in div with jquery
<div class='container'>
<div class='some_class'><img src='../images.jpg' alt='images' /></div>
</div>
Tnaks!
sorry, I'd like tu put in this div not onli this images but element also ???
ex:
<div class='container'>
<div class='some_class'>
<img src='../images.jpg' alt='images' />
<strong>text</strong>
</div>
</div>
Upvotes: 3
Views: 176
Reputation: 5221
$(".container img").wrap('<div class="some_class"></div>')
There are some great documentation at http://docs.jquery.com/Main_Page
Upvotes: 0
Reputation: 1075
You could do this, easy and quick:
$(".container img").wrap("<div class='some_class'></div>");
You can also build the nodes yourself, but with jquery this is a fine answer.
Upvotes: 0
Reputation: 125486
u can use wrap inner plug in
<script>
$('.myimage').wrapInner('<div><\/div>');
</script>
http://motherrussia.polyester.se/jquery/wrapinner/
Upvotes: 0
Reputation: 104178
If you have an id for the image, you can use wrap:
$("#myimg").wrap("<div class='some_class'></div>");
Upvotes: 1
Reputation: 26141
$(".container img").wrap("<div class=\"some_class\"></div>");
Check out the Wrap documentation
Upvotes: 5