Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery - Select image by alt or title

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">
like image 723
Thomas Depole Avatar asked Jan 31 '12 04:01

Thomas Depole


2 Answers

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});
});
like image 181
Joseph Silber Avatar answered Oct 13 '22 20:10

Joseph Silber


Try:


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

like image 26
Sudhir Bastakoti Avatar answered Oct 13 '22 20:10

Sudhir Bastakoti