Action on selected name fails.
I've got a simple select box with some names in my html form. I want to show a div when 'Tom' is selected in the select box, but somehow it doesn't seem to work.
Please note that I want to check the names, not the select values.
- $(document).ready(function() {
- $('#pgroup').change(function() {
- if ($('#pgroup option:selected').text() === 'Tom') {
- alert ("hi");
- $(".complete").show();
- }
- });
- });
And my html:
- <select name="pgroup" style='width:150px;'>
- <option value=newboxes1>Jenny</option>
- <option value=newboxes2>Tom</option>
- </select>
- <div class="complete" name="complete" style="display:none;">hello</div>