Hi everyone! I'm very new to JQuery, and I'm having some trouble understanding how to do this:
I have an image of class "imgexpander" with the src attribute set to "img1.png". When the image is clicked on, it should look to see whether a div with class "expand" is currently hidden or visible.
- If it's hidden (which is the default), it shows it (I know how to use show()) and changes the src attribute of the image to "img2.png".
OR:
- If the div is visible, it hides it and changes the src attribute of the image to "img1.png".
I'm not familiar with the available functions in JQuery yet. How could this be accomplished? Can you give me some sample code that I can work with?
Thanks in advance!
UPDATE: I forgot to add a detail: is it possible to somehow make the onclick of an image of class "imgexpander" only influence divs that are all included together in one big div? So, the hierarchy would be something like:
- big div
- image with onclick
- div that needs to be influenced
- another big div
- image with onclick
- div that needs to be influenced
The desired result would be to have each "image with onclick" only influence "divs that need to be influenced" inside its respective "big div". Is this possible? I'm not sure the current answer would fit, but thanks!