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

129
Views
Is there a way to change a p element's innerHTML based on an img src that changes in a slideshow?

I currently have some variables that are strings which should go into my p tag's innerHTML depending on the img src thats currently displayed from a slideshow array. onload it should display the variable product1info (which is just a string) and if I hit next or previous in the slideshow the img source changes. Based on that img source the product1info should change to the string that matches the img src. i.e. product1info, product2info, product3info etc.

This is part of my code right now and I'm not sure what this if statement should look like but i think this is where it needs to be fixed:

var imgsource = document.getElementById('slide').src; //this is the img slideshow where I get src from

var infosub = document.getElementById('info'); //this is the paragraph where I am trying to write the productinfo variables

function info(){
    if (imgsource == 'productt1.jpg'){
        infosub.innerHTML = product1info;
    }
}
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!