unwrap()方法是jQuery中的一个内置方法,用于从选定元素中删除父元素。
null
语法:
$(selector).unwrap()
参数: 此方法不接受任何参数。
返回值: 此方法返回所选元素,其中包含unwrap()方法所做的更改。
下面的示例演示了jQuery中的unwrap()方法:
例子:
<!DOCTYPE html> < html > < head > < title >The unwrap Method</ title > < script src = </ script > <!-- jQuery code to show the working of this method --> < script > $(document).ready(function() { $("button").click(function() { $("p").unwrap(); }); }); </ script > < style > div { width: 300px; height: 100px; background-color: lightgreen; padding: 20px; font-weight: bold; font-size: 20px; border: 2px solid green; } span { background-color: yellow; } </ style > </ head > < body > < div > <!-- click on this span element --> < p >Welcome to < span >GeeksforGeeks!.</ span ></ p > < button >Click Here!</ button > </ div > </ body > </ html > |
输出:
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END