<div class="replacedDiv">this is the replaced div</div>

<script>
            $(function(){
                $("div.replacedDiv").after("<p>i will replace the div</p>").remove();
            });
</script>

结果是新建的p替换了原来的div。

note: 总是可以将有用的语句封装起来形成jquer拓展

$.fn.replaceWith = function(html){

  return this.after(html).remove();

}

利用这个拓展,执行上面的效果可以用这个语句:

$("div.replaceDiv").replaceWith("<p>i will replace the div</p>");

最新文章

  1. H3 BPM:为石化企业提供一个不一样的全停大修平台
  2. Tcl internal variables
  3. Python cumsums和cumprod函数
  4. Knockout.js随手记(4)
  5. 在asp.net mvc中上传大文件
  6. 多次快速点击相同button导致重复响应的问题
  7. Objective-c 中的变量
  8. 凭证(Credential)
  9. underscore.js 源码阅读 准备
  10. JAVA常用加密解密算法Encryption and decryption
  11. ubuntu python的升级与回滚
  12. xunit-ICollectionFixture
  13. Markdown 指南
  14. The difference between ppp and ndis
  15. java 多线程 33: 多线程组件之 Callable、Future和FutureTask
  16. OSGi 系列(一)之什么是 OSGi :Java 语言的动态模块系统
  17. TITLE: BizTalk Server 2013 Administration Console
  18. OpenCV 脸部跟踪(1)
  19. HDU 1045 dfs + 回溯
  20. 初尝微信小程序2-Swiper组件、导航栏标题配置

热门文章

  1. 移动端一个奇怪的触摸bug
  2. java学习基础部分
  3. 1093 字符串A+B (20 分)
  4. [Alpha]Scrum Meeting#3
  5. 评估指标:ROC,AUC,Precision、Recall、F1-score
  6. Scrapy——settings配置文件
  7. 用PL/sql连接oracle 弹窗出现 could not resolve the connect identifier specified 这个错误
  8. Request.QueryString 的用法
  9. Golang框架beego和bee的开发使用
  10. ios 得到每周的星期一开始和星期天结束的日期