Hello!
I am running a random image script on my 404 page; each time the page is loaded, a random image will be shown:
http://philrules.com/blarg (it's the main image on the page, not the little image in the top-right corner)
I'm not new to jQuery, but I usually don't write my own scripts.
What I'm trying to do is add text to the paragraph — which hold the image — that will change depending on the image that is shown. However, since each image is loaded into the same img container (class="shuffle"), I am trying to change the text based on the src attribute.
After searching for solutions, I had pieced together this poop-stain of a function which, unsurprisingly, doesn't work:
- $(function(){
- if ("img.shuffle[src=http://philrules.com/new_images/404-04.gif]") {
- $("p").append("<b>Hello, world</b>");
- }
- if ("img.shuffle[src=http://philrules.com/new_images/404-5.png]") {
- $("p").append("<b>Goodbye, world</b>");
- }
- });
The .append part works, but it adds the text to the page regardless of what the image src is.
Any help or information would be greatly appreciated! Even if someone can just point me to a good resource or reference on how to make this work.