How do I create a function for my website where I have 5 divs in a container with a width of 20% each? When I click on one div, I want it to expand to 40% while the other divs shrink to 15%. Then, when I click on the expanded div again, it should return to its original size. Additionally, I want the transition between divs to be smooth.
Although I found an example online, I am new to JavaScript and struggling to understand it. Can someone provide me with a simple function that achieves the same effect?
Here is the example I came across: