使用jQuery删除链接,但不删除图像 [英] using jquery to remove links, but not images

查看:61
本文介绍了使用jQuery删除链接,但不删除图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含一堆列表项的列表项,每个列表项都有一个包装在超链接中的图像.我正在尝试编写一些jQuery,它将删除链接,但不会删除图像.这可能吗?

I have a that has a bunch of list items, each with an image wrapped in a hyperlink. I'm trying to write some jQuery that will remove the links, but not the images. Is this possible?

推荐答案

如果您未运行1.4:

$("a:has(img)").each(function() { $(this).replaceWith($(this).children()); })

这篇关于使用jQuery删除链接,但不删除图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆