I suggest that component authors use the code I gave you. I also suggest to style by class instead of by id since the clientId should be a dynamic, runtime value that is not known at build time.
If components have a static clientId, they can not (legally) be used in a loop.