JSFiddle - React, Tailwind, and code Playground

by Neo Aptt

HTML

<select id="select_domain">
    <option value="1">Jon Doe</option>
    <option value="2">Max Mustermann</option>
</select>
<span id="domain"></span>

JavaScript

/*Binds a change event to your select*/
$('#select_domain').change(function () {
    /*sets the text to the selected option of THIS select box*/
    set_text($('option:selected', this).text());
});
/*Creates a function to set the text of domain
This function can be used elsewhere as well*/
function set_text(text){
    $('#domain').text(text);
}

/*This triggers the function and sets the text 
to the currently selected text on page load*/
set_text($('#select_domain option:selected').text());