Multiple buttons with different ID’s to one Variable

So im trying to make different languages for a user terminal. The way you select one is by clicking on an image with the corresponding country flag, which changes the language to the national language of the country. My thoughts on how to do that would be that upon click, the button would change the value of a variable which in change would alter the displayed language. My first thought on how to implement that would be with switch case, but i really just dont know how to program it.

This is what i got so far, but when i tried it with alert, it didnt work:

var languages = "";
        $('#UK, #FR, #SP, #HU, #IN, #CH, #JA, #SK, #BU').click(function() {
                case "#UK":languages = 'UK';break;
                case "FR":languages = 'FR';break;
                case "SP":languages = 'SP';break;
                case "HU":languages = 'HU';break;
                case "IN":languages = 'IN';break;
                case "CH":languages = 'CH';break;
                case "JA":languages = 'JP';break;
                case "SK":languages = 'SK';break;
                case "BU":languages = 'BU';break;

I, in theory could also just make the same followup page 10x and let the buttons load those pages, but i wouldnt be satisfied with that. Also im sorry if this is a stupid question, im still very new to js.


The id of your clicked element seems to exactly match the language you want to set, so simply do that.

let languages = "";
$('#UK, #FR, #SP, #HU, #IN, #CH, #JA, #SK, #BU').on('click', function() {
    languages =;