Let's say I have the following div:
<div class="device iphone5 black"></div>
I want a toggle button to change devices. Therefore, the classes should be changed. But, not only .iphone5 should be replaced, the color .black should be replaced as well.
I have the following array:
var devices = [
'.iphone5 .black',
'.nexus5',
'.iphone4s .black',
'.lumia920 .blue',
'.s5 .white',
'.htc-one'
];
How can I make a switcher that checks if a div with the .device class has one of the classes defined in the array, and then replace it by the next one? Something like:
<script>
$('.device').filter(devices.join())$('.device').is(devices.join("")
.attr('class', 'device ' + devices[NEXT]);
</script>