Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery为没有alt标记的图像提供边框_Jquery_Html_Css - Fatal编程技术网

jQuery为没有alt标记的图像提供边框

jQuery为没有alt标记的图像提供边框,jquery,html,css,Jquery,Html,Css,如何在没有alt标签的情况下给图片加边框,我试过了,但是我很绿,所以可能完全是废话 $( ':image:not([alt])' ).css('border', '5px solid red'); jQuery中没有:image选择器,您需要使用: $('img:not([alt])').css('border', '5px solid red'); 你就快到了 首先,使用:image是不正确的。你必须使用 $("image") 选择图像 另一种选择是使用 [type="image"]

如何在没有alt标签的情况下给图片加边框,我试过了,但是我很绿,所以可能完全是废话

$( ':image:not([alt])' ).css('border', '5px solid red');

jQuery中没有
:image
选择器,您需要使用:

$('img:not([alt])').css('border', '5px solid red');
你就快到了

首先,使用:image是不正确的。你必须使用

$("image")
选择图像

另一种选择是使用

[type="image"]
为了可读性。您可以在此处阅读更多内容:

然后使用

:not()
允许您指定选择器。也可以使用.not(),并使用逗号或空格分隔选择器。参考:

因此,要选择页面上没有alt属性的所有图像,请执行以下操作:

$("image:not(alt)").css('border', '5px solid red');
希望这有帮助。

$('img:not([alt])).css('border','5px solid red')这是一把小提琴: