You don't have to do it like that, you can simply use an anchor tag (< a>) to link to an image directly if that is what you wish to do.
Also, reconsider renaming your images with something more Search Engine friendly than img2334 or some such, better puppy-dog.jpg than img22334.jpg
Post some sample code and it will be easier to help.
You can experiment on jsfiddle (http://jsfiddle.net). That also makes it easy for me to modify your code and demo it.