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

73
Vistas
src.match is considered null despite being defined?

I have one issue, I dont understand why this src.match is considered invalid


PUG (HTML)

 .mainSplitContainer.mainRectangleContainerReverse
    .splitContainer.column8
      .responsiveTextTitle.highlightText.rectangleContainer
          | RESPONSIVE ECONOMY
          .responsiveText.responsiveText
            |With its flux econonomy system, get an economy that responds to your actions instantly and requires you to adapt to the changes in the battlefield!
    .splitContainer.column4
      .splitItem.rectangleItem 

          //what actually matters from the html
        .splitImage#rectangleEconomy
          img(src='../img/resources.jpg' alt='')


Javascript

  let ecoPicture = document.getElementById("rectangleEconomy");
  setInterval(changeImage, 10000);
  function changeImage() {

    if (ecoPicture.src.match("resources")) {
      console.log("yesyesyes");
    }
    else {
      console.log("nonono");
    }
  }

Don't know why it returns this error

Uncaught TypeError: Cannot read properties of null (reading 'src')

its not null because #rectangleEconomy is defined? How to solve this issue? Yes my script is beneath all the HTML at changeImage (index.js:242:18)

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