Tomasz Tomasz - 1 month ago 15
Javascript Question

Using tags to select group of pictures in gallery

I'd like to create gallery. I have buttons: all, mobile, desktop, shop etc. Pictures are located on server and has assigned tags. For example one picture tags: all, mobile, shop. How to assign tags in html ? To the class, data attributes or another way ? After press button I'd like to show only one type pictures for example with mobile tag.

Answer

if you already have your pictures generated in html page, you can use something like <img data-tag="mobile-desktop" src="link" /> to make the image tag be mobile and desktop. based on the click, using javascipt, you simply filter images whose data-tag attribute contains the tag you want. If you need further the, tell it in comment

Comments