Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
how to replace items when using intersection observer

Pretty new to code so forgive me if I stumble around some wording here, but I'm trying to use IntersectObserver to show a specific image when its corresponding text is shown in a scroll menu. Right now the appropriate images appear when the text is shown in the scroll menu, however, they appear in a flexbox column type manner and I would like them to replace each other once the text is no longer intersecting with the scroll menu. Are there any ideas how I might be able to do this?

const observer = new IntersectionObserver(entries => {
  entries.forEach(elem => {
    if (elem.isIntersecting) {
      const append = $(elem.target).append()
      const text = $(elem.target).text()

      
      switch (append, text) {
        case 'ALEX':
          $('.image-content').append("<img class='img' src='images/ALEX.gif'/>")
          break
        case 'CHANEL':
          $('.image-content').append("<img class='img' src='images/CHANEL.gif'/>")
          break
        case 'LAURA':
          $('.image-content').append("<img class='img' src='images/LAURA.gif'/>")
          break
        case 'NATHAN':
          $('.image-content').append("<img class='img' src='images/NATHAN.gif'/>")
          break
        case 'RON':
          $('.image-content').append("<img class='img' src='images/RON.gif'/>")
          break
        case 'STACEY':
          $('.image-content').append("<img class='img' src='images/STACEY.gif'/>")
          break
        case 'VINCE':
          $('.image-content').append("<img class='img' src='images/VINCE.gif'/>")
          break
        default:
          $('.image-content').text(`Sorry, no more companions available ${text}.`)
      }
    }
  })
})

// Select all the options in the left
$('.companion-names').each(function () {
  // For each item we want to observe whether it is visible using the function above
  observer.observe(this)
})
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda