after() 和 remove() 实现替换
2024-08-27 20:04:33
<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>");
最新文章
- H3 BPM:为石化企业提供一个不一样的全停大修平台
- Tcl internal variables
- Python cumsums和cumprod函数
- Knockout.js随手记(4)
- 在asp.net mvc中上传大文件
- 多次快速点击相同button导致重复响应的问题
- Objective-c 中的变量
- 凭证(Credential)
- underscore.js 源码阅读 准备
- JAVA常用加密解密算法Encryption and decryption
- ubuntu python的升级与回滚
- xunit-ICollectionFixture
- Markdown 指南
- The difference between ppp and ndis
- java 多线程 33: 多线程组件之 Callable、Future和FutureTask
- OSGi 系列(一)之什么是 OSGi :Java 语言的动态模块系统
- TITLE: BizTalk Server 2013 Administration Console
- OpenCV 脸部跟踪(1)
- HDU 1045 dfs + 回溯
- 初尝微信小程序2-Swiper组件、导航栏标题配置
热门文章
- 移动端一个奇怪的触摸bug
- java学习基础部分
- 1093 字符串A+B (20 分)
- [Alpha]Scrum Meeting#3
- 评估指标:ROC,AUC,Precision、Recall、F1-score
- Scrapy——settings配置文件
- 用PL/sql连接oracle 弹窗出现 could not resolve the connect identifier specified 这个错误
- Request.QueryString 的用法
- Golang框架beego和bee的开发使用
- ios 得到每周的星期一开始和星期天结束的日期