//更换两个元素的位置

var exchange=function (el1, el2) {
  var ep1 = el1[0].parentNode,
  ep2 = el2[0].parentNode,
  index1 = Array.prototype.indexOf.call(ep1.children, el1),
  index2 = Array.prototype.indexOf.call(ep2.children, el2);
  ep2.insertBefore(el1, ep2.children[index2]);
  ep1.insertBefore(el2, ep1.children[index1]);
}

exchange($(".class1"),$(".class2"));
//class1与class2要是相同父级下的元素
例:

执行后 exchange($(".btns .ok"),$(".btns .cancel"));

最新文章

  1. java.lang.NumberFormatException: For input string: "1608020001 " 错误
  2. swift的运算符
  3. js事件捕获,事件冒泡,事件委托以及DOM事件流
  4. ZOJ 1041 Transmitters
  5. mapreduce任务中Shuffle和排序的过程
  6. Tornado,表单处理,一样在行
  7. HTML5表单内元素的required属性
  8. [PHP]MemCached高级缓存
  9. Timer.3 - Binding arguments to a handler
  10. Codeforces 442C Artem and Array(stack+贪婪)
  11. paper资料
  12. 微信小程序如何开发制作
  13. web.config中的configSource
  14. harris角点检测的简要总结
  15. volatility内存取证
  16. trinitycore 魔兽服务器源码分析(二) 网络
  17. npm 安装React Devtools调试工具
  18. python的字符串连接操作符+
  19. ios开发UI篇--UIStepper
  20. C语言不定型参数函数定义

热门文章

  1. Linux设备驱动程序 之 装载和卸载模块
  2. BFS,优先队列优化
  3. PIMPL(private implementantion)模式(转载)
  4. Oracle 报错 ORA-03290的处置
  5. React入门----基础篇
  6. linux centos6.5 环境下安装redis的过程
  7. Aria2Gee 教程
  8. xshell一些简单的使用---1
  9. 一百零三:CMS系统之使用sweetalert提示框优化返回结果
  10. C# CRC16 modbus