Am I allowed to add whatever attributes I want to HTML tags such that I can retrieve their value later on using javascript? For example:
You can. The page will not pass verification, however most browsers will accept it.
It is almost certainly the wrong way of doing it. Try using class="hasTooltip_yes tipcolour_yellow"