Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

405
Visualizações
this javascript code is not working. it doesnt have an error but when i open the website images have to change with the background color
<ul class="thumb">
        <li> <img src="images/thumb1.png" onclick="imgSlider('img1.png');changeCircleColor('#017143')"></li>
        <li> <img src="images/thumb2.png" onclick="imgSlider('img2.png');changeCircleColor('#eb7495')"></li>
        <li> <img src="images/thumb3.png" onclick="imgSlider('img3.png');changeCircleColor('#017143')"></li>
    </ul>

maybe i did something wrong in here i dont know. but when i click on the small image the big image have to change to that image and the backgroud is going to change at the same time. so that java code is not working but my editor says it has no error what should i do.

<ul class="sci">
    <li><a href="#"> <img src="images/facebook.png"></a></li>
    <li><a href="#"> <img src="images/twitter.png"></a></li>
    <li><a href="#"> <img src="images/instagram.png"></a></li>

</ul>

</section>

<script type="text/javascript" >
    function imgSlider(anything){
        document.querySelector('.starbucks') .src = anything;
    }

    function changeCircleColor(color){
        const circle = document.querySelector('.circle');
        circle.style.background = color;
    }
</script>
  

when i delete this script part nothing changes. what did i do wrong

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I didn't understand ur problem exactly but i will try to help u out first of all i wouldn't recommend to put 2 functions at the same time like u did here

<li> <img src="images/thumb1.png" onclick="imgSlider('img1.png');changeCircleColor('#017143')"></li>

regarding your javascript code you can combine ur both functions in a single one like this

function changeImageAndCircleColor(anything, color){
    document.querySelector('.starbucks').setAttribute('src', anything);
    const circle = document.querySelector('.circle');
    circle.style.background = color;
}

ur html should looks like this:

<li> <img src="images/thumb1.png" onclick="changeImageAndCircleColor('img1.png', '#017143')"></li>
// and so on....

this may not solve ur problem, so please make your question more clear to know ho to help, and where's ur starbucks and circle element?? provide us with more details about ur code

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda