Experiencing difficulties with my image slider and struggling to determine the cause

Trying to create an image slider, but I'm encountering numerous challenges. It seems like everyone finds it easy to do, but for me, it's a struggle. I've been following along with this tutorial.

Watch Tutorial Here

However, the buttons don't work as expected, and the images are not fitting inside the container. At this point, even if only three images show up, I just want it to function properly.

I intended for one picture to display at a time, but instead, two or more pictures are appearing together in the container.

Since I am relatively new to this, I will continue trying to understand and solve the issue as it is essential for my personal project. Can anyone assist me by explaining what I might be doing wrong?

HERE IS MY CODE:

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="gallery.css">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
...
(same HTML code as provided)
...

CSS:

*{
    padding:0px;
...(CSS details can be added if needed)...

JAVASCRIPT:

const carouselSlide = document.querySelector('.slide');
...(JavaScript code can be added if needed)...

Answer №1

Immediately noticeable is the issue with spaces between the counters and '++' on the event listeners, which will prevent it from functioning correctly.

Here's a tip: From my experience as a novice programmer, 90% of the time it turned out to be a simple typo or something missing causing frustration. Rather than getting upset, try taking a brief pause and checking for these common errors.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The current_time() function displayed an incorrect time value

When I utilized the current_time() function in PHP to retrieve the current time, it displayed an incorrect time. Instead of the correct time, it is showing 12 hours and 30 minutes earlier than the actual current time, even after modifying the php.ini file ...

"Troubleshooting: Angular ng-show not triggering correctly upon first loading of the

Utilizing Angular's ng-show directive to adjust the display of questions in a quiz and show a result upon completion, everything is functioning as intended except for the initial question. Upon loading the quiz, $scope.image is initialized as false. S ...

Converting Django variables into formatted HTML content

My Django project involves passing strings to my HTML template. def media(request, media_id): specificMedia = get_object_or_404(Stream, pk=media_id) channel = str(specificMedia.channel) urldata = "http://www.twitch.tv/widgets/live_embed_player ...

Looking to transform a nested JSON structure into a visually appealing HTML table with merged rows?

My JSON structure appears as follows: $scope.data = [ { "type":"Internal", "count": 3, "library" : [ { "type":"Library 123", "count": 2, "version" ...

Implementing Undo and Redo capability for input tag in Angular: A step-by-step guide

I need help creating a feature in Angular that allows users to undo and redo values entered in an input field. Here's what I want to achieve: if I type Hello into the input: Click the undo button: display hell Click the undo button: display hel Click ...

Is there a way to split each foreach value into distinct variables?

I am looking to assign different variables to foreach values. I have fetched data from an API in JSON format, and then echoed those values using a foreach loop. My goal is to display the echoed value in an input box using JavaScript. I attempted the follow ...

"Following successful POST login and session storage in MongoDB, the session is unable to be accessed due

When sending login data by POST with the credentials: 'include' option from client server 5500 to backend server 3000, I ensure that my session data is properly stored in MongoDB thanks to the use of 'connect-mongodb-session'. In the ba ...

A guide on resetting a Nodemon server using code

At the beginning of server start, I have an array of JSON objects that are updated. But if I make changes to the JSON data using NodeJS FS instead of manually editing it, Nodemon does not restart. Is there a way to programmatically restart nodemon? ...

Toggle the display of slider for multiple IDs with a show/hide feature

After browsing through a jQuery slider toggler tutorial on w3schools, I was inspired to create my own. However, I wanted a more flexible approach where I wouldn't have to rigidly define CSS styles and jQuery functions. Unlike the implementation on w3 ...

Transferring information using JavaScript, converting it to JSON format, and then passing it to PHP

In my search for answers to a common question on stackoverflow, I've come across various solutions involving sending data through the ajaxvariable.send() portion of an ajax call. However, I'm considering using a different approach that I haven&ap ...

What steps should be taken to ensure that Google effectively crawls through an AngularJS application?

According to a source at Allotment Digital, it is unnecessary to provide different or pre-rendered content to Google when using html5mode and removing hashtags from URLs. While some websites state that ajax crawling documents are deprecated, others such a ...

Video margins within a webview

After numerous attempts to embed a YouTube video in a WebView, I'm still struggling with a persistent small margin on the right side of the video. I've researched similar issues and attempted to address it through JavaScript adjustments without ...

Beginner with webpack encountering autoprefix issues while using webpack manifest plugin

My attempt to use the webpack manifest plugin to create a manifest.json file containing keys and values for my assets with contenthash in their names has hit a snag. The issue is that the values in the manifest file have the prefix "auto" attached to them, ...

Storing information in an array based on a specific flag

Currently, I am developing an Angular application where I am dealing with a specific array that contains a flag named "checked". Based on the value of this flag, I need to perform certain manipulations. Here is a snippet of my sample data: const data = [{ ...

Utilize the grid system from Bootstrap to style HTML div elements

I am working on my angular application and need help with styling items in a Bootstrap grid based on the number of elements in an array. Here's what I'm looking to achieve: If there are 5 items in the array, I want to display the first two items ...

Selecting a dropdown value dynamically after a form submission in ColdFusion using jQuery

I created a basic form with the use of an onload function to populate market values by default. However, I encountered an issue where after selecting a market value from the drop-down list and submitting the form, the selected value does not stay selected ...

Template Function Problem Detected in AngularJS Formatting

I'm struggling to incorporate my scope attributes into a template function within my custom directive. The formatting for the return section in my template is not working as expected. This is how it currently looks: angular .module(' ...

TypeScript compiler encountering issue with locating immutable.js Map iterator within for of loop

I am currently facing a challenge with using immutable.js alongside TypeScript. The issue lies in convincing the TypeScript compiler that a Map has an iterator, even though the code runs smoothly in ES6. I am perplexed as to why it does not function correc ...

What are the steps to create a dynamic background image that adjusts to various

When viewing the website on a computer screen, the entire cat is visible in the background image. However, when switching to a mobile screen size, only a portion of the cat is displayed, appearing as though it has been cut off. The image is not smaller on ...

Utilizing CSS to create a zoom effect on hover for an image while preserving its original size was successful, however, the issue arises as only a corner of the image is visible

On my webpage, I have implemented an image that zooms in slightly when hovered over. Unfortunately, this animation has caused the image to only display one part regardless of whether hover is activated or not. I've attempted to troubleshoot by adjusti ...