Actin based on selected option
I'm trying to get a comand to run instantly when a user selects an option from the select options. My code looks like below.
- <select title="" name="marital_status" id="marital_status">
- <option value=""></option>
- <option value="Dating">Dating</option>
- <option value="Divorced">Divorced</option>
- <option value="Married" selected="">Married</option>
- <option value="In a Committed Relationship">In a Committed Relationship</option>
- <option value="Single">Single</option>
- <option value="Separated">Separated</option>
- <option value="Widowed">Widowed</option>
- </select>
- <h1>I believe in God</h1>
jQuery
- $(document).ready(function() {
- if ($('#marital_status option:slected').value == "Married") {
- $('h1').hide();
- }
- });
Fiddle link