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?
- Ajax Load More Posts in Category Page
- Disable WordPress’ blogging functionality and disable ‘posts’
- How to create WP Editor using javascript
- Dynamically update post title in admin page
- how to display full post with pagination on home page
- 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
- Showing random content / pictures from earlier posts in a sticky post?
- Side by side blog posts that are tied together
- How to show a full post, not just an excerpt
- Convert a complex webpage into WP theme
- How to get the post’s parent ID?
- Injecting JavaScript into a Post with WP3.x
- How can I get a post field value using javascript?
- Blog Posts not showing title
- How blog page in WordPress works : blog page retrieve first post ID
- Custom post preview without saving
- Why is my Blog Page ID == First Post ID?
- Displaying Latest Posts on a Page
- Add blogs to “Blogs i Follow” sidebar [closed]
- How to make number of blog posts a custom field?
- Block Editor: Reset Reusable Blocks to last saved record
- How can i display gallery shortcode output under Post text
- Display posts from a different website on Genesis Responsive Slider
- WP Bakery Load More Button loads the same posts
- add new post default view
- Show certain posts in a LIST format that members have been granted access to
- Ajaxify This Code
- 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
- In post.php how can I remove onbeforeunload?
- Why won’t pagination work?
- Navigate through the posts using keyboard arrows
- How to create a page that shows the last 10 posts?
- How to get the latest URL of my blog?
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- How to set a certain Custom Template to a Single Blog Post
- Sidebar on single.php not showing up
- Get content from WordPress posts in Boostrap modal window – Javascript side?
- Where is the “Posts”/”Blog” template?
- Insert specific information to a posts of a predefined category
- How to separate each individual blog post?
- Direct some posts to only appear on a specific page
- posts and cms and posts again
- 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?
- Create a List of Widgets, where each widget holds three attributes
- Why is it recommended to insert JS through the theme, plugin, etc rather than in the post directly?
- WordPress React re-rendering to many times
- Sticky Post Doesn’t always work
- Post Image Gallery After Content Function messes with other content
- 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?
- WordPress empty page! what is wrong with this code?
- Use posts from old db by changing prefix
- Bulk find & replace on WordPress posts/pages (minus image paths)
- 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 Page doesn’t show summary but full content
- How to generate an HTML link automatically from URL in a users’ post
- Ajax post doesnt call succes after got the response
- Get posts from category from custom query
- My posts page is missing the page title
- Multiple Pages – Seperate blogs
- Word /blog/ in slug post, problems in CPT. Solutions?
- Colorbox not working on native WordPress gallery when gallery is loaded thru AJAX
- Loading posts outside wordpress
- Front end post delete error confirmation and success message
- Edit Posts Page but not category specific pages?
- Link post to blog from a static page
- Hide first blog post in content and output it in widget
- 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
- long blog post on self hosted wordpress blog not displayed
- 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
- The page that displays Posts on homepage
- How to add a widget area between blog posts in Genesis Framework?
- How to save the same post in multiple blogs?
- 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?
- How do I save JS classes being applied to the WP dashboard via custom plugin?
- Permalink issue with new blog posts > getting 301 redirect
- WordPress custom post_status after 6.6 version