How To Select a Specific Option Based on a Condition
I have a table with many rows. Each row contains a select drop down with only 2 options, "Active" and "Deactivated". I wish to offer the user an alert message based on which option they select. The code I have can not distinguish one select from another select. And so returns "true" no matter which option I have selected. I have spent days hunting through SO and nothing works.
Here is the HTML Snippet:
- <td class="category_select"><select class="edit_cat" name="category_value[]"><option value="active" selected="selected">Active</option><option value="deactivated">Deactivated</option></select></td>
Here is the Jquery I have, which does not distinguish between the two options.
- $(".category_select").on("click",".edit_cat", function() {
- if($(".category_select").has('option:contains(Deactived)'))
- { console.log('true'); }
- else{console.log('false')}
- });