Greetings I have been trying this for hours now and I am having trouble trying to figure it out. I am new to javascript and jquery. For example I have two images, a black and blue image. I have 4 black images that when hovered individually, changes the img src to blue, and goes back to black when hovered out. What I am trying to accomplish is that when you click the image/link, it will stay "blue". It will only change to "black" once you click on the other images.
Here is what I have so far:
HTML
<a id="catlnk1" href="javascript:void(0);" onclick="loadCat(1)"><img src="/images/blogpage/published.png" onmouseover="this.src='/images/blogpage/published-active.png'" onmouseout="this.src='/images/blogpage/published.png'" alt="Published" />
Script
function loadCat(num)
{ if (num == 1){
$("#catlnk" + num).attr("src","/images/blogpage/published-active.png");
} else if (num == 2){
$("#catlnk" + num).attr("src","/images/blogpage/upcoming-active.png");
} else if (num == 3){
$("#catlnk" + num).attr("src","/images/blogpage/opening-active.png");
} else if (num == 4){
$("#catlnk" + num).attr("src","/images/blogpage/job-active.png");
}
}
Sorry if the code is messy, I'm new to this.