JSFiddle - React, Tailwind, and code Playground
HTML
<select>
<option selected>
</option>
</select>
Length of selected option value: <span id="result"></span>
JavaScript
var
$r = $('#result'),
$o = $('select option:selected'),
result = '';
result += $o.val().length;
// option changed: https://github.com/jquery/jquery/commit/92cbf5362cfe4fe52e919eecfebe8ecbe27ee5e3
// Try jquery.text
try{
result += '. jQuery.text of element returns length: ' + jQuery.text( $o[0]).length.toString() + '. ';
}catch(ex){
result += '. jQuery.text failed. ';
}
// Try element.text
try{
result += 'element.text returns length: ' + $o[0].text.length.toString() + '.';
}catch(ex){
result += '. element.text failed.';
}
$r.text( result );