Your jQuery is a little inefficient. Also, alerts should only be used for debugging, not for production code, since some browsers allow to permanently disable alerts. You should find another way, e. g. with modal overlays or something like that.
As to your problem: we need to see your HTML, too, in order to give you the most appropriate solution.
Donít click this link!