简体   繁体   English

jQuery:隐藏除Recaptcha图像以外的所有图像

[英]Jquery: Hide all images except recaptcha image

i need a code in Jquery for hide all images on all pages except the 'reCaptcha' thing. 我需要在Jquery中的代码来隐藏除“ reCaptcha”外的所有页面上的所有图像。 The images of reCaptcha start with the link: 'google.com/recaptcha' or 'recaptcha.net' ... My idea is to make the script that hide all images but not touch the images that contains the part 'recaptcha'. reCaptcha的图像以链接开头:“ google.com/recaptcha”或“ recaptcha.net”。我的想法是使脚本隐藏所有图像,但不要触摸包含“ recaptcha”部分的图像。 Is possible to make in Jquery? 可以在Jquery中进行吗? Thanks in advance and to all. 在此先感谢所有人。 Kind Regards. 亲切的问候。 Luca. 路卡

像这样吗

$('img:not([src*=recaptcha])').hide();

First run $("img").hide(); 首先运行$("img").hide(); then simply put an ID on the captcha tag and run $("#ID").show(); 然后只需将一个ID放在验证码标签上,然后运行$(“#ID”)。show();

Or if you can't use an ID tag, cycle through all images in a loop and check what's in the src attribute, or even use a regex selector . 或者,如果您不能使用ID标签,则循环遍历所有图像并检查src属性中的内容,甚至使用regex选择器

The ReCaptcha script puts all of its generated markup within a <div id="recaptcha_widget_div"> ReCaptcha脚本将其所有生成的标记放入<div id="recaptcha_widget_div">

Having said that, you can grab all images except those within this DIV like this... 话虽如此,您可以像这样在DIV中抓取所有图像...

$("img:not(#recaptcha_widget_div img)").hide();

Or if that is too ugly, you can hide all images and re-show the ReCaptcha ones like this... 或者,如果太丑陋,您可以隐藏所有图像,然后像这样重新显示ReCaptcha。

$("img").hide();
$("#recaptcha_widget_div img").show();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM