日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php中append,插入节点append()、insertAfter()的特殊用法:对原有DOM元素进行移动

發布時間:2025/3/11 php 52 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php中append,插入节点append()、insertAfter()的特殊用法:对原有DOM元素进行移动 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

插入節點的方法: append()/appendTo()、prepend()/prependTo()、after()/insertAfter()、before/insertBefore()

這些插入節點的方法不僅能將新創建的DOM元素插入到文檔中,也能對原有的DOM元素進行移動(若對已在文檔中存在的元素使用插入節點的方法則相當于執行“移動節點”的操作)

實例↓

實現效果: 點擊測試按鈕,將所有.test標簽里面的內容都移到該標簽外面并刪除所有的.test標簽

無標題文檔

*{margin:0;padding:0;}

ul li{ list-style:none;}

img {border:0 none;}

body {padding:100px;}

input[type='button']{width:100px; height:38px;display:block;position:fixed;right:20%; top:50px;}

p{color:#f00;}

div{ color:#000; border:1px blue solid;}

div span{ display:block;}

$(function(){

$("input[type='button']").focus().click(function(){

$(".test >span").each(function(index, element) {

$(this).insertAfter($(this).parent()).prev().remove();

});

})

})

1、看不到class屬性2、看不到class屬性3、看不到class屬性

提示:你可以先修改部分代碼再運行。

當然也可以直接使用replaceWith()方法來實現上面的替換效果

無標題文檔

*{margin:0;padding:0;}

ul li{ list-style:none;}

img {border:0 none;}

body {padding:100px;}

input[type='button']{width:100px; height:38px;display:block;position:fixed;right:20%; top:50px;}

p{color:#f00;}

div{ color:#000; border:1px blue solid;}

div span{ display:block;}

$(function(){

$("input[type='button']").focus().click(function(){

$(".test >span").each(function(index, element) {

var this_html=$(this).parent().html();

$(this).parent().replaceWith(this_html)

});

})

})

1、看不到class屬性2、看不到class屬性3、看不到class屬性

提示:你可以先修改部分代碼再運行。

總結

以上是生活随笔為你收集整理的php中append,插入节点append()、insertAfter()的特殊用法:对原有DOM元素进行移动的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。