wrapping dynamically in a div

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?
Who is Participating?
c lConnect With a Mentor Commented:
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/
c lCommented:
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/
All Courses

From novice to tech pro — start learning today.