There is a line of iPhones, it is known that different models have different body colors, for example, knowing that the user has chosen the iPhone 5s to display only div blocks with gray silver gold colors? Yes, it can be organized through:

if (модель телефона==5s) { скрыть все цвета показать gray показать silver показать gold } else if { и тд } 

But I would like a more logical solution, maybe there are ideas? When clicking on the phone model, the model number is taken from the corresponding data-model attribute, 4 5 5c 5s and so on. I thought to create an object with all the models and colors, and check it out with it, but I don’t know how to organize it all.

  • arrange var colors = { '5': ['red', 'white'], '5s' : ['green', 'yellow'], ...} - teran

1 answer 1

You can do it through jQuery based on this video . Attach an object of the form {модель1: [цвет1, цвет2, цвет3]} , and then almost the same as in the example.