星空网 > 软件开发 > Java

after() 和 remove() 实现替换

<div >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>");

 




原标题:after() 和 remove() 实现替换

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

Spinrewriter:https://www.goluckyvip.com/tag/25650.html
SpinX Games:https://www.goluckyvip.com/tag/25651.html
spirittea:https://www.goluckyvip.com/tag/25652.html
Splash Wines:https://www.goluckyvip.com/tag/25653.html
Splio:https://www.goluckyvip.com/tag/25655.html
Split:https://www.goluckyvip.com/tag/25656.html
怪物在游轮上复活的电影 怪物在游轮上复活的电影叫什么:https://www.vstour.cn/a/411230.html
在线旅游如何选择更优惠的旅游产品?:https://www.vstour.cn/a/411231.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流