jquery處理Html文件

2021-10-08 08:25:16 字數 828 閱讀 6786

i would like to say: 

hello

結果:

案例1:把所有匹配的元素用其他元素的結構化標記包裹起來。

hello

結果:

案例2:用原先div的內容作為新div的class,並將每乙個元素包裹起來

hello

goodbye

$('.inner').wrap(function() );
結果:

hello

goodbye

empty()

刪除匹配的元素集合中所有的子節點,刪除的是元素內部的東西

hello

remove()

從dom中刪除所有匹配的元素,刪除的是元素本身

hello

jquery 文件處理

兩個引數乙個將來是父,乙個將來是子 1 appe ndto 父 1 prependto 父 將1節點插入到父容器的最後乙個節點之後 第乙個子節點之前 父 appe nd 1 父 prepend 1 實現的是和上述一樣的功能 after before兩個引數最終會是兄弟關係 1.after 2 將2插...

JQuery文件處理

p ap pend fun ctio n in dex,html ret urni ndex 這個 集合中的 索引值 htm l 這 個物件原 先的ht ml值 1.2ap pend to c onte nt 把 所有匹配 的元素追 加到另一 個指定的 元素元素 集合中。使用這個 方法是顛 倒了常規...

jQuery 文件處理

this is a paragraph.this is another paragraph.在每個 p 元素的結尾新增內容 在每個 p 元素的結尾新增內容 方法作用 向每個匹配的元素內部追加內容。引數介紹 content 要追加到目標中的內容。用法示例 html 為i come from i lov...