I want to loop over an array continuously on click. Extra props if you can work in a delay between class switches 🙂
I got this far:
// Define word
var text = "textthing";
// Define canvas
var canvas = 'section';
// Split word into parts
text.split();
// Loop over text
$(canvas).click(function() {
$.each(text, function(key, val) {
$(canvas).removeAttr('class').addClass(val);
});
});
Which is not too far at all 🙂
Any tips?
The following will wait until you click the selected element(s) in the var
el. In this examplevar el = $('section')will select all<section>...</section>elements in your document.Then it will start cycling through the values in
cssClassNames, using each, in turn as the css class name on the selected element(s). A delay ofdelayInMilliswill be used between each class change.