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

124
Visualizações
Javascript issue in combination with OWL caroussel

I'm trying to code an OWL caroussel. This is working fine. Inside the caroussel I have 2 items with an intro text. This will be more items later. By clicking on a button, the text is swapped with another text. This is working fine when not using the OWL-caroussel. As soon as i'm using the caroussel, this function is not working anymore.

Here is my script:

<script>
            function changeText() {
                    var id=document.getElementsByName("button")[0].id;
                    if(id==1){
                        document.getElementById("text").innerHTML = "<?php echo the_sub_field('content_1'); ?>";
                        document.getElementsByName("button")[0].id=0;    
                    }else {
                        document.getElementById("text").innerHTML = "<?php echo the_sub_field('intro_1'); ?>";  
                        document.getElementsByName("button")[0].id=1;  
                    }
                }
            </script>
            
            <?php $image = get_sub_field('image_1');
                if( !empty($image) ): ?>
                <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" class="img-fluid" />
            <?php endif; ?>
            <p id="text"><?php echo the_sub_field('intro_1'); ?></p>
            <button name='button' id='1' onclick="changeText()">Change Text</button>

I'm also using ACF, but replacing that with normal text I see the same behaviour.

I'm not seeing any errors in console, so i do not know why this isn't working with OWL-caroussel.

Demo: see https://sun.devwiw.nu/demo/

regards, Roland

about 4 years ago · Juan Pablo Isaza
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