I am trying to stream-line some code that I believe is a little sloppy. Basically a script that checks to see the value of a select box and shows or hides a div based on the value selected. I want to check the value on load as well as on change. Is there a cleaner way to do this?
// Required items
$(document).ready(function(){
if($("#credentials").attr("selectedIndex") == "None") {
$('#CDiv').show();
}else{
$('#CDiv').hide();
}
$("#credentials").change(function(){
if ($(this).val() == "None" ) {
$('#CDiv').show();
} else {
$('#CDiv').hide();
}
});
});
I appreciate any help with this. I am still a little green on jQuery. Thanks!