我有这段代码
<div class="superdiv">
<div></div>
<div></div>
</div>
我想将所有.superdiv
个子div包装成一个名为<div class="subdiv"></div>
我该怎么做?
由于
答案 0 :(得分:2)
您可以使用.wrapInner()
method:
private String _currentFileName;
public void SaveEntry(bool saveAs)
{
if (saveAs || String.IsNullOrEmpty(_currentFileName))
{
saveFileDialog1.InitialDirectory = Application.StartupPath;
saveFileDialog1.FileName = "FormData.bin";
var result = saveFileDialog1.ShowDialog();
// TODO: handle user cancellation
_currentFileName = saveFileDialog1.FileName;
}
using (var writer = new StreamWriter(_currentFileName))
{
// TODO: do stuff with your writer
}
}
您还可以在子元素上使用.wrapAll()
method:
$('.superdiv').wrapInner('<div class="subdiv"></div>');
答案 1 :(得分:0)
尝试以下
$(".superdiv > div").wrapAll("<div class='subdiv'/>");