Cant migrate JS from HTML
-
Hi
In HTML JS was:<script src="carousel.js"></script> <script> const myCarousel = new Carousel({ container: document.querySelector('.slider'), items: document.querySelectorAll('.slider__item'), displayControls: false, controlsContainer: document.querySelector('.slider__controls'), autoplay: true, autoplayTime: 3500 }); </script>I added to a functions.php:
<?php function wpb_adding_scripts() { wp_register_script('carousel', get_template_directory_uri() . '/carousel.js','','1.1', $in_footer = true); wp_enqueue_script('carousel'); } add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts' ); ?>Rest of the JS I tried to add to a Header and a Footer:
<script> const myCarousel = new Carousel({ container: document.querySelector('.slider'), items: document.querySelectorAll('.slider__item'), displayControls: false, controlsContainer: document.querySelector('.slider__controls'), autoplay: true, autoplayTime: 3500 }); </script>By using *Insert Headers and Footers, JS Simple Custom CSS and JS and even manualy but nothing works.
JS on HTML web working good: https://truegenealogist.com/wp-content/themes/theme/index.html
Bud with WP: https://truegenealogist.com/Any suggestions?
ThanksThe page I need help with: [log in to see the link]
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
The topic ‘Cant migrate JS from HTML’ is closed to new replies.