I need to paste src to image depending on color choice.
Here is my markup:
<div data-img="[black-blue.png]" black blue></div>
<div data-img="[black.png]" black></div>
<div data-img="[blue.png]" blue></div>
<div data-img="[orange.png]" orange></div>
<div data-img="[black-blue-orange.png]" black blue orange></div>
<div data-img="[blue-orange.png]" blue orange></div>
<div data-img="[blue-red-orange.png]" blue red orange></div>
My script works on elements attributes:
var attributes = '';
for(var i = 0; i<activeColorsArray.length; i++ ){
attributes += '['+activeColorsArray[i]+']';
}
Output: [blue][black], for examples. It's works for black&blue item, but it's catch black&blue&orange element too.
[blue][black]:not([orange]) not working for me because I have 8 colors...
Need something like ONLY THIS selector.
One idea is to consider the number of attributes an element has. If you want to target only
blueandblackthen you target the elements with only 3 attributes (includingdata-imgin your case)