Skip to main content

Forums

This topic contains 1 reply, has 2 voices, and was last updated by  JeroenR 1 week ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #295429

    JamiePattison
    Participant

    I have this code https://codepen.io/desandro/pen/htsui working as it is found at https://masonry.desandro.com/events.html

    This page loads with all tiles purple. You will note everytime you click a purple tile it changes to yellow.

    How could i create a link so when i enter it into a browser the appropriate tile is showing as coloured (yellow) on page load?

    #295556

    JeroenR
    Participant

    You could make use of ID’s on your elements, match these ID’s in your URL and read them in the onload function like this:

    window.onload = () => {
    const item = document.querySelector(window.location.hash);
    if (item) {
    item.classList.add('grid-item--gigante');
    }
    };

    Optionally followed by msnry.layout();.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

icon-link icon-logo-star icon-search icon-star