select Option based on value

by Akram kamal

HTML

<select>
    <option value="US" text="United states" />
    <option value="CA" text="Canada" />
    <option value="Mx" text="Mexico" />
</select>
<div></div>

JavaScript

$("select").change(function () {
    var country = $(this.options).filter(":selected").attr("text")
    $("div").text(country)
}).change()