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

122
Views
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
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!