Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

78
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!