logo, sports bar, jquery event handler
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
let root = document.documentElement // Used for css variables
|
||||
|
||||
let selectedSports = []
|
||||
|
||||
$(".sport").on("click", function() {
|
||||
$(this).toggleClass("selected")
|
||||
|
||||
let sportName = $(this).children()[1].innerHTML // 2nd element, which is the sport name
|
||||
|
||||
|
||||
let index = selectedSports.indexOf(sportName)
|
||||
if (index > -1 ) { // If element is found in array
|
||||
selectedSports.splice(index, 1) // Remove sport at index
|
||||
} else {
|
||||
selectedSports.push(sportName) // Add sport to array
|
||||
}
|
||||
|
||||
$(this).trigger("selected", [selectedSports.includes(sportName), selectedSports]) // Trigger event
|
||||
})
|
||||
|
||||
function getCSSVariable(name) {
|
||||
return getComputedStyle(root).getPropertyValue(name)
|
||||
}
|
||||
Reference in New Issue
Block a user