What happens if you use .css("display","none")
instead of .style.display = "none"
?
So that it looks like this:
var myIndex = 0;
carousel();
function carousel() {
var i;
var listItem = document.getElementsByClassName("js--slider-item");
for(i = 0; i < listItem.length; i++) {
listItem[i].css("display", "none");
}
myIndex++;
if(myIndex > listItem.length) {
myIndex = 1;
}
listItem[myIndex-1].css("display", "block");
setTimeout(carousel, 3000);
}
And what do you get, if you console.log() you’re listItem[i]
?
EDIT:
My bad, .css() is, of course, jQuery.
Related Posts:
- Keyboard shortcut for updating a page or post?
- Disable WordPress’ blogging functionality and disable ‘posts’
- Get the current post ID as a variable in Javascript
- Dynamically update post title in admin page
- How do I convert a mathematical Microsoft Word document to a WordPress blog post?
- widget should display post archive by year and on click also by month
- Add javascript when post is published
- Get post from custom REST endpoint in Gutenberg
- blog page showing only first post
- Single Post Gallery Using Shortcode
- Add confirmation popup on “Move to Trash”
- How to share same post to multiple site in wordpress?
- Create a separate JS application for an individual post?
- Convert a complex webpage into WP theme
- Custom excerpt length filter doesn’t work
- How to get the post’s parent ID?
- Add scripts on custom post add/edit pages Not Working
- Injecting JavaScript into a Post with WP3.x
- Limit Gutenberg blocks available to users to choose from
- Remove certain post-formats from showing in blog?
- How blog page in WordPress works : blog page retrieve first post ID
- Blog Posts in Custom Menu
- Custom post preview without saving
- Why is my Blog Page ID == First Post ID?
- Add blogs to “Blogs i Follow” sidebar [closed]
- Choose whether to automatically add a taxonomy with the same name as the post
- Show certain posts in a LIST format that members have been granted access to
- Ajaxify This Code
- Append class to posts page
- Integrate OpenStreetMap on WordPress
- How to disable WordPress blog folder
- How could I change my Permalink from blog to custom structure? [closed]
- Posting blog entries in screenplay format
- Single.php – Get Current Parent Category
- How to remove in-line style of WordPress’s post content only?
- Only show a Post once in 10 visits
- WP move posts to different path
- In post.php how can I remove onbeforeunload?
- Append ‘Continue Reading’ link if post length is more than 3 lines of text?
- older blog posts not showing in new theme
- Why won’t pagination work?
- WordPress Query Posts From Category Post on Static Page
- How to create a page that shows the last 10 posts?
- Call current post URL in ajax
- How to get the latest URL of my blog?
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- Exclude post category in a blog page
- Get content from WordPress posts in Boostrap modal window – Javascript side?
- Where is the “Posts”/”Blog” template?
- WordPress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
- Using the loop to set locations for all posts on a single google map
- How to separate each individual blog post?
- Insert JavaScript in a blog post or a new page?
- Changing The Default Header POST Title and Description text by category in wordpress
- Separate blog and reviews categories
- why my urdu text is not aligned properly when written in wordpress blog post?
- Why is it recommended to insert JS through the theme, plugin, etc rather than in the post directly?
- Older blog posts not showing up on WordPress
- Pagination not give another posts
- “Blog pages show at most” in setting not working
- Sticky Post Doesn’t always work
- Single Post Gallery Using Shortcode
- How can I create a ‘sub-blog’ which has its own sidebar on individual posts?
- blog post not accesible on click [closed]
- How to fix wordpress blog post error? Can anyone help to fix this issue?
- How to pull sticky post permalink inside php?
- WordPress empty page! what is wrong with this code?
- Use posts from old db by changing prefix
- Pagination Stops
- How to backup WP blog posts to computer, not new site
- Customizing a new page used for blog posts with Avada theme
- Blog featured images disappeared on my homepage
- Blog images not showing on homepage
- Blog Page doesn’t show summary but full content
- How to generate an HTML link automatically from URL in a users’ post
- Get posts from category from custom query
- Multiple Pages – Seperate blogs
- testing result of $.post with json_encode
- Loading posts outside wordpress
- How to put the WordPress blog into theme
- Why the blog posts is not showing?
- Edit Posts Page but not category specific pages?
- Blog styling in SASS
- Link post to blog from a static page
- Hide first blog post in content and output it in widget
- How can I have the posts from one word press blog show on the presentation page of another word press site
- Page updates appear in Preview but not live version?
- new blog post does not appear in blog after publishing
- Posts don’t appear on the Blog page
- Get image paths from RSS feeds
- 2 tick boxes appearing below comments
- Wanting to apply different featured images for each post
- WordPress Custom Theme: My site shows the same posts on Page 1 and Page 2 and so on [duplicate]
- Post only showing on homepage when Logged in – direct URL still working
- Posts not showing up on Blog page
- How to save the same post in multiple blogs?
- How to hide a script ( an ad) from a specific post? [closed]
- WP Rest API feature image breaking react component
- Need to show birthday of custom post type(Famous people in this case) in elementor. Date of birth set in custom fields
- How can I add a custom caclulation form in post?