JSFiddle - React, Tailwind, and code Playground

by Sam_Butler

HTML

<select name="orderemaillocal" id="orderemaillocal" onchange="updateThis(this,'mh_order_email','order_id','11031.00','email_id');"><option disabled="disabled" selected="selected"></option><option value="129">[email protected]</option><option value="166">[email protected]</option><option value="11">[email protected]</option></select>

<div id="output"></output>

CSS

#output {
    border: 1px red solid;
}

JavaScript

$("#orderemaillocal").change(function() { //Works when you change the select (try removing disabled to see effect)
    if($(this).val()) { //Checks if the value is truthy - see http://stackoverflow.com/questions/5515310/is-there-a-standard-function-to-check-for-null-undefined-or-blank-variables-in
        var val = $(this).val()
        $("#output").text(val);
    } else {
        $("#output").text("Value is falsy");
    }
});
$( document ).ready(function() { //Does the above on page load
        if($("#orderemaillocal").val()) {
        var val = $("#orderemaillocal").val()
        $("#output").text(val);
    } else {
        $("#output").text("Value is falsy");
    }
});