JSFiddle - React, Tailwind, and code Playground
HTML
<button class="hobbies">hobbies</button>
<button class="sledding">sledding</button>
<button class="personal">personal</button>
<button class="food">food</button>
JavaScript
var GLOBAL_CATEGORIES = ['hobbies', 'sledding'];
$(window).load(function() {
var categories = ['personal', 'food'];
// local categories
$.each(categories, function (index, value) {
$('.' + value).click(function() {
alert(value);
return false;
});
});
// Global categories
$.each(GLOBAL_CATEGORIES, function (index, value) {
$('.' + value).click(function() {
alert(value);
return false;
});
});
});