An identical copy of a picture collection designed to showcase photographs

I currently have a photo gallery script embedded in my website:

<script async src="//jsfiddle.net/karimabdlehamee/tmLswek3/3/embed/js,html,css,result/dark/"></script>

While it works perfectly on my site, I encountered issues when trying to display multiple instances of the gallery on the same page.

How can I set up two or more separate instances without affecting the display of the photo gallery?

I tried duplicating the instance by simply copying the divs in the HTML code.

Answer №1

The identifier for an element in your HTML structure must be unique. To address this, you can modify the script to target a CSS class or repeat the function call.

FOR INSTANCE

let container = document.getElementsByClassName("container");

for (let i = 0; i < container.length; i++) {
  //Execute script
}

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

Is there a way to specifically transmit ComponentArt CallbackEventArgs from a JavaScript function during a callback?

One of the challenges I'm facing involves implementing a callback in my ComponentArt CallBack control using javascript when the dropdown list is changed. I specifically want to pass both the control and the associated ComponentArt.Web.UI.CallBackEvent ...

Saving JSON data into an HTML element using Handlebars templating

Is there a way to save the entire JSON object within an HTML element as a data attribute? let a = {name : "sample", age : "34"} $.find('#someDiv').data('adata', a); Is it possible to achieve the same result using Handlebars when creat ...

Avoid activating ng-blur when ng-keydown is triggered in AngularJS

Currently, I am working on a project involving angularJS and I am facing an issue with the execution of ng-blur conflicting with ng-keydown. The problem arises because ng-keydown causes the element to lose focus at a certain point. The HTML code in questi ...

Using Symfony to access Twig templates from both frontend JavaScript and backend controllers

The primary method I employ templates is the standard Symfony approach - calling from controller: return $this->render('MyBundle:MyController:MyTemplate.html.twig'); This template is located in Resources/views/MyController/MyTemplate.html.tw ...

Although React JS and lodash are meant to handle state changes, it appears that the state is not being

I need to update the value of an element at a specific level using lodash, but I'm facing some issues. What I'm doing is making a copy of the object and then applying lodash's set method on the copy to modify the original object. However, ...

Steps to execute scripts within a React application without the presence of an index.html file

I'm fairly new to React and I have a React web app where I need to incorporate multiple scripts. The challenge is that these scripts should be placed within the body tag in the index.html file, like this: <!DOCTYPE html> <html lang="en&q ...

Encountering difficulties when attempting to inject NotifierService into an Angular Service

I am attempting to incorporate Angular NotifierService into my service class so that I can display error notifications in case of any exceptions from the service side. I attempted to inject a bean of NotifierService in the constructor of my service class, ...

Arranging the Logo and hamburger menu for optimal visibility

I am having trouble aligning a CSS hamburger menu next to my logo. I have placed both the CSS hamburger and the logo in the header. Although I was able to float the logo to the right, it is not on the same line as the menu. After the header, I would like ...

There seems to be an error with JVectorMap: the <g> attribute transform is expecting a number but is instead receiving "scale(NaN) translate(N..."

Hey there! I'm currently working on creating a form with a map to select the country of birth using JVectorMap. However, when checking the Google Chrome developer console, I encountered the following error message: jquery-jvectormap-2.0.5.min.js:1 Err ...

The interaction between a JavaScript function call and C# is not functioning properly

Attempting to invoke the JavaScript function from CodeBehind ( C# ) : function scrollToBottom() { window.scrollTo(0, document.body.scrollHeight); } The function successfully executes when directly called from my asp.net application. However, ...

Several purposes for eventListener Callback

Within the layout is an html table and span element. The goal is to have the values of value1 and value2 on each row added together and displayed in the sum cell of that same row. Additionally, all the values for value1, value2, and Sum in both Row 1 and R ...

Do you always need to use $scope when defining a method in Angular?

Is it always necessary to set a method to the $scope in order for it to be visible or accessible in various parts of an application? For example, is it a good practice to use $scope when defining a method that may only be used within one controller? Consid ...

Websocket session has ended

Delving into the world of webSockets, Angular, and Play framework has been a rewarding journey so far. I've been utilizing https://github.com/AngularClass/angular-websocket for seamless integration with Angular. The connection setup like this: var da ...

The div element is experiencing a resizing issue

I am currently working on the following HTML markup: <div class="card" style="height:100%"> <div class="controlPanelContainer"> <div class="card" style="background-color:yellow;height:200px"> </div> <div class= ...

What is the best way to retrieve an AJAX response from a different domain?

Are there alternative methods to retrieve AJAX response and access data from a different domain without requiring changes on the server-side code? While YQL offers this feature, it comes with limitations such as a maximum of 1000 calls per hour for free u ...

Access the style of the first script tag using document.getElementsByTagName('script')[0].style or simply refer to the style of the document body with document.body.style

Many individuals opt for: document.getElementsByTagName('script')[0].style While others prefer: document.body.style. Are there any notable differences between the two methods? EDIT: Here's an example using the first option: ...

Adjusting the width of the search bar in a Bootstrap inline form

Issue: The search box is not resizing with the page and I can't figure out how to make it wider. Adding styles like width: 100%; hasn't worked so far. In addition, the select dropdown box in the image linked below appears slightly clipped on the ...

During the rendering process, the property "instance" was attempted to be accessed but is not defined

I am having trouble creating a Contact Us page using v-model. My code keeps throwing these errors: Property "inputted_name" was accessed during render but is not defined on instance Property "inputted_email" was accessed during render but is not defined o ...

html form submission error - please refresh

After submitting a form on my page, I keep encountering an error every time I try to refresh the page. I've attempted several solutions that I came across online, but none of them have resolved the issue as I continue to face this error on different ...

Utilize the match() method in JavaScript to target and extract a whole paragraph

I am attempting to extract an entire paragraph from a text file using JavaScript and then display it in an HTML element. Despite reading numerous posts and articles, I have been unable to find the correct regex formula. Here is an excerpt from the text fil ...