what i'm trying do: when element class listed in array clicked, class (and class) should passed function.
i know below incorrect, hope illustrate trying accomplish:
var arr = ['.clickable-1', '.clickable-2', '.clickable-3', '.clickable-4', '.clickable-5']; $(arr).click(function(){ alert('this class got clicked: ' + $(this).prop('class')); });
create multiple selector selector string array...
$(arr.join(',')).on('click', function() { console.log('this class got clicked:', this.classname); })
note if element has multiple classes, ie
<button class="clickable-1 clickable-2 something-else and-another"> click me </button>
they shown in classname
property.
Comments
Post a Comment