JSFiddle - React, Tailwind, and code Playground

by Evan Sharp

HTML

<select>
    <option value="1">The first option</option>
    <option value="2">The middle option</option>
    <option value="3">The last option</option>
</select>
<p>See console outpout.</p>

JavaScript

var select = 'select' // this just shows that the selector for the select is a var
$(select).on('change',function(){
    console.log("$(select).val():",$(select).val());
    console.log("$('option:selected',select).val():",$('option:selected',select).val());
    console.log("$('option:selected',select).text():",$('option:selected',select).text());
}).change();