Show Field If Certain Option Value Is Selected - Must Work On Pageload
This genius code works fine for checkboxes: $(document).ready(function() { $('#Languages-spoken-and-understood-8').change(function() { $('#li-2-21')[$(this).is(':checked')
Solution 1:
You're almost there, this would be a much shorter way of doing it:
$('#Severity-of-your-symptoms').change(function() {
$("#li-10-14")[$(this).val() == "full01_severity_other" ? 'show' : 'hide']("fast");
}).change();
When getting or setting the value of a <select>
(or any other input type element) you can use .val()
. In case anyone wants this without the animation, it'd look like this:
$('#Severity-of-your-symptoms').change(function() {
$("#li-10-14").toggle($(this).val() == "full01_severity_other");
}).change();
Post a Comment for "Show Field If Certain Option Value Is Selected - Must Work On Pageload"