Data-Attribute in Images

Is there a way to add a data-attribute to an image?
I am trying to add an html5 template for an image scratch off. It uses jquery and the ScratchCard plugin.

This template requires a data-attribute for the two images.

How would I go about doing this? If this cannot be done in Hype, how can I create an image into a scratch card?
Thanks so much!


Hi Marian!

I do not have a direct answer for You - but if You enter “ScratchCard” into the Forum’s search field - there will be several hits. “Scratch Card” will yield a couple additional ones.

Hi @MResio

You can run a function on scene load that sets an element’s attribute to whatever you need.

var el = hypeDocument.getElementById('myElement');
el.setAttribute('data-whatever', 'property-you-want-to-set');

Also, as you’ve mentioned jQuery then this is how you do it using that.


but as @JimScott says there a few posts here that show techniques on implementing scratch cards in Hype.

1 Like

Thank you DBear!

1 Like

Thank you JimScott!

1 Like