So you wrote 18 lines of php instead of <a href="…"><img src="…" onclick="…" /></a>.
Nice.
First of all, it can be browser optimization (clicking on the link can stop browser from doing extra jobs, because he is about to leave this page anyway). You should move your click handler to <a>:
<a href="…" onclick="…"><img src="…" /></a>.
Next, open js debug console and see if there are any errors.
Last, look at generated HTML code, maybe you’ll see the problem.
PS. Some tips:
You can use one image for normal and hover states. Google for css sprites.
You can use "this" inside handler functions. It points on element itself.
You can use pseudo-class "hover" for doing most of the job for you.
Thanks Orey for your quick response, but now I’m confused. I’d read in the forum the use of the Ctml class instead of the html tag <a> or <img> directly in the view, that is the reason for the 18 lines. So what do you suggest?
If It’s better the use use of CHtml class I don’t know how to implement the CSS sprites, that is, the use of the CSS’s background-image property, if I’am using the CHtml::image. I need to link with an image not a word.
Thank you for tip #2, I’ll use it.
Do you have an example of tip #3, I don’t understand, do you have a simple code’s example?