I'm having an issue getting two sets of functions to work correctly. I have a change function that shows and hides a div that works as intended but can not get the window.onload function to correcly work when loading the page and not affecting how the .change functions work.
Function Script:
<script src="~/Scripts/jquery-2.0.3.js"></script>
<script>
$(function () {
window.onload = function () {
if ($("#SelectedGenderId").val() == "3") {
$(".gender-description").show();
} else {
$(".gender-description").hide();
}
if ($("#SelectedSettingId").val() == "1") {
$(".setting-description").show();
} else {
$(".setting-description").hide();
}
}
$("#GenderId").change(function () {
if ($("#GenderId").val() == 3) {
$(".gender-description").show();
} else {
$(".gender-description").hide();
}
});
$("#SettingId").change(function () {
if ($("#SettingId").val() == 1) {
$(".setting-description").show();
} else {
$(".setting-description").hide();
}
});
});
</script>
The .change functions work as expected but the .onload does not. Am I using the .onload correctly?