如下代码 如何交换 #a 与#b 的位置
整个DOM交换
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <style type="text/css"> b { display:block; } #a { background:red; width:100px; height:35px; margin:10px; } #b { background:#666; width:100px; height:35px; margin:10px; } </style> <body> <div id="a" class="a"><b>11</b></div> <div id="b" class="c ae"><em>22</em></div> <div style="background:#963; width:100px; height:100px;" id="oDiv">点击</div> </body> </html> <script src="jquery-1.11.1.min.js"></script> <script type="text/javascript"> $(function(){ $("#oDiv").on({ click:function(){ var a=$("#a").html(); alert(a); } }) }) </script>
时间: 2024-10-12 03:42:30