如何使用jQuery让孩子成为父母的父母?

时间:2015-10-14 21:58:14

标签: javascript jquery html

我有这个

Traceback (most recent call last):
File "setup.py", line 18, in <module>
setup_requires=['py2app'],
File "/Users/Apollo/miniconda/lib/python2.7/distutils/core.py", line 151, in          setup
dist.run_commands()
File "/Users/Apollo/miniconda/lib/python2.7/distutils/dist.py", line 953, in   run_commands
self.run_command(cmd)
File "/Users/Apollo/miniconda/lib/python2.7/distutils/dist.py", line 972, in   run_command
cmd_obj.run()
File "/Users/Apollo/miniconda/lib/python2.7/site- packages/py2app/build_app.py", line 659, in run
self._run()
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/py2app/build_app.py", line 865, in _run
self.run_normal()
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/py2app/build_app.py", line 959, in run_normal
self.create_binaries(py_files, pkgdirs, extensions, loader_files)
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/py2app/build_app.py", line 1214, in create_binaries
platfiles = mm.run()
File "/Users/Apollo/miniconda/lib/python2.7/site- packages/macholib/MachOStandalone.py", line 105, in run
mm.run_file(fn)
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/macholib/MachOGraph.py", line 84, in run_file
self.scan_node(m)
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/macholib/MachOGraph.py", line 110, in scan_node
m = self.load_file(filename, caller=node)
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/macholib/MachOGraph.py", line 93, in load_file
newname = self.locate(name, loader=caller)
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/macholib/MachOStandalone.py", line 23, in locate
newname = super(FilteredMachOGraph, self).locate(filename, loader)
File "/Users/Apollo/miniconda/lib/python2.7/site-packages/macholib/MachOGraph.py", line 49, in locate
loader=loader.filename)
TypeError: dyld_find() got an unexpected keyword argument 'loader'

我希望将其转化为:

<div class="a" foo="bar">
  <div class="b">
    <!-- various things here -->
  </div>
</div>

使用jQuery。我该怎么做?

3 个答案:

答案 0 :(得分:2)

要保留events和处理程序,请使用clone()

&#13;
&#13;
$(function () {
  a = $(".a").clone();
  a.find(".b").remove().end().html($(".b").html());
  $(".b").unwrap().html("").append(a);
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div class="a" foo="bar">
  <div class="b">
    <!-- various things here -->
  </div>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

除了显示的html之外没有任何特定标准可以:

$('.a').html( $('.b').html()).wrap('<div class="b">');

DEMO

答案 2 :(得分:0)

按如下方式使用......

$('.b').insertBefore($('.a'));
$('.b').append($('.a'));