I have a drop-down (<select id="typeselect">
) with an inline onchange
event handler to alert the selected option. Why do I get the error: undefined is not a function
?
Demonstration below:
(function($) {
function test() {
var selected_option = $('#typeselect option:selected');
alert(selected_option);
}
})(jQuery);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="typeselect" onchange="test()">
<option>(Select)</option>
<option value="oi">Outgoing invoice</option>
<option value="ii">Incoming invoice</option>
<option value="oc">Outgoing Credit Nota</option>
<option value="ic">Incoming Credit Nota</option>
</select>