Solved

wrapping dynamically in a div

Posted on 2014-07-17
2
299 Views
Last Modified: 2014-07-18
I have 2 divs next to each other.
div class=space
div class=space

how can i use jquery to add a wrapper around both div's that use selector space?
0
Comment
Question by:rivkamak
  • 2
2 Comments
 
LVL 2

Expert Comment

by:c l
ID: 40202955
give this a shot:

$( ".space" ).wrap( "<div class='new'></div>" );

Open in new window


more info on the wrap() function - http://api.jquery.com/wrap/
0
 
LVL 2

Accepted Solution

by:
c l earned 500 total points
ID: 40202966
sorry, i mis-read your question, you want it wrapped around BOTH divs, so use this instead:

$( ".space" ).wrapAll( "<div class='new' />");

Open in new window


more info on wrapAll() function - http://api.jquery.com/wrapall/
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
forgetful about js objects 8 47
binding event to form in window.open 9 41
how to use .length with "input" 2 25
formvalidation.io validate form on class click 4 18
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question