Skip to content
Advertisement

How to make html code less repetitive using PHP?

I have a slider with various elements in it and when clicking on a button on a particular element will open a pop-up contain specific details to that selected element. Now my slider is becoming really long and I have been wondering if I can use either JavaScript or anything to make my code look nice and remove the repeating pattern of my code Below is my code:

JavaScript

In my code I have numerous slides and when clicking on the button Learn More should open another code which repeat itself as follows:

JavaScript

Is there a way for me to continue add other slides and modal in a way that would reduce the repeated HTML pattern in JavaScript or PHP while keeping the integrity of my code?

Advertisement

Answer

You can use a single modal and some javascript to populate that modal.

Below is just an example:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement