Preview:
$('#satuan').on('select2:select', function (e) {
        const value = $(this).val();
        
        if (value === 'new') {
            const promptValue = prompt('Tambah List:');
            
            if (promptValue) {
                const data = {
                    id: promptValue,
                    text: promptValue,
                }
                const newOption = new Option(data.text, data.id, false, false);
                $('#satuan')
                    .append(newOption)
                    .trigger('change')
                    .val(promptValue);
            }
        }
    });
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter