使用适当的SRC隐藏所有图像,包括某些条件

hide all the images with the appropriate SRC, including some conditions

本文关键字:图像 包括某 条件 隐藏所 SRC      更新时间:2023-09-26

我想隐藏页面中具有特定src属性的每个图像,除了具有以/dailyTickets/front/user.form.php/dailyTickets/front/user.php开头的href属性的父a元素的图像。

我使用这个方法,但它用src隐藏了所有图像,在a测试中,他就是找不到img来完成他的工作

$('img[src='"/dailyTickets/pics/aide.png'"]').hide();
$('img[src='"/dailyTickets/pics/aide.png'"]').parent('a[href^='"/dailyTickets/front/user.form.php'"]').show();
$('img[src='"/dailyTickets/pics/aide.png'"]').parent('a[href^='"/dailyTickets/front/user.php'"]').show();

有人能帮忙吗?

您的问题是在父项上使用show(),而不是图像本身。试试类似的东西:

$('a[href^='"/dailyTickets/front/user.form.php'"]').find('img[src='"/dailyTickets/pics/aide.png'"]').show();

也许这就是您所需要的:)https://www.npmjs.com/package/location-hide

即使您从未使用过node.js

,它也很容易使用