用jQuery将3个div合二为一 [英] Wrap 3 divs in one with jQuery

查看:66
本文介绍了用jQuery将3个div合二为一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用jQuery将3个div包装为一个.

I need to wrap 3 divs into one using jQuery.

<div class="one"></div><div class="two"></div><div class="three"></div>

进入此

<div class="wrap"><div class="one"></div><div class="two"></div><div class="three"></div></div>

我该怎么办?

非常感谢您的提前帮助

推荐答案

$('.one, .two, .three').wrapAll('<div class="wrap">');

$('.one, .two, .three').wrapAll( $('<div>').addClass('wrap') );

参考: http://docs.jquery.com/Manipulation/wrapAll

这篇关于用jQuery将3个div合二为一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆