JQuery - 通过 alt 或标题选择图像

发布于 2025-01-01 06:27:04 字数 388 浏览 5 评论 0原文

你好,我需要这个 JQuery 来运行下面的图像。但这是我需要通过 alt 选择图像的技巧,我似乎无法让 JQuery 选择它

<script>                                    
 $('img[alt="800px-Red_Bull"]').onload = function() {
 Pixastic.process(img, "desaturate", {average : false});
</script>

<img width="800" height="387" src=".../01/800px-Red_Bull.png" alt="800px-Red_Bull" title="800px-Red_Bull">

Hello I need this JQuery to run for the image bellow it. But here's the trick I need to select the image by it's alt, I can't seem to get the JQuery to select it

<script>                                    
 $('img[alt="800px-Red_Bull"]').onload = function() {
 Pixastic.process(img, "desaturate", {average : false});
</script>

<img width="800" height="387" src=".../01/800px-Red_Bull.png" alt="800px-Red_Bull" title="800px-Red_Bull">

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑忘罢 2025-01-08 06:27:04

您的问题不在于您的选择器,而是您没有正确使用 load 事件。

将您的代码更改为:

$('img[alt="800px-Red_Bull"]').load(function() {
    Pixastic.process(img, "desaturate", {average : false});
});

Your problem is not with your selector, it's that you're not using the load event correctly.

Change your code to this:

$('img[alt="800px-Red_Bull"]').load(function() {
    Pixastic.process(img, "desaturate", {average : false});
});
倒带 2025-01-08 06:27:04

尝试:


$('img[alt="800px-Red_Bull"]').load(function () {
 Pixastic.process(img, "desaturate", {average : false});
});

Try:


$('img[alt="800px-Red_Bull"]').load(function () {
 Pixastic.process(img, "desaturate", {average : false});
});

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文