I want to hide a Div when a radio button is checked using jquery. My Jquery code works on page Load, but when the user refreshes the IE browser, then the hide is changed to show. Below is my code and any help will be appreciated.
$("[name='Radios']").click(function () {
if ($("input:radio.Radio base:checked")) {
$("#EmployeeSelection").hide();
}
I want to hide a Div when a radio button is checked using jquery. My Jquery code works on page Load, but when the user refreshes the IE browser, then the hide is changed to show. Below is my code and any help will be appreciated.
$("[name='Radios']").click(function () {
if ($("input:radio.Radio base:checked")) {
$("#EmployeeSelection").hide();
}
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
50 Points
182 Posts
Jquery hide a div when radio button is checked resets to show when IE browser refreshes
Mar 05, 2019 08:15 PM|denkyira|LINK
I want to hide a Div when a radio button is checked using jquery. My Jquery code works on page Load, but when the user refreshes the IE browser, then the hide is changed to show. Below is my code and any help will be appreciated.
$("[name='Radios']").click(function () {
if ($("input:radio.Radio base:checked")) {
$("#EmployeeSelection").hide();
}
});
<label type="radio" value="2" name="Radios">
<input name="RadioButton" class="Radio base" id="checkbox" type="radio"
</label>
<div id="EmployeeSelection">
<div>
<h4>
<span>Documents</span>
</h4>
</div>
</div>
All-Star
52221 Points
23292 Posts
Re: Jquery hide a div when radio button is checked resets to show when IE browser refreshes
Mar 05, 2019 08:47 PM|mgebhard|LINK
Store the state of the div in a database table, Session, or Cookie.
Contributor
3710 Points
1431 Posts
Re: Jquery hide a div when radio button is checked resets to show when IE browser refreshes
Mar 06, 2019 06:11 AM|Yuki Tao|LINK
Hi denkyira,
You can use $.cookie("key", value) to set the value, and $.cookie("key") to get the saved value.
And then determine the condition in the initialization function of the page,to display or hide div.
A small tutorial on how you use cookies in jQuery:
https://www.electrictoolbox.com/jquery-cookies/
Best Regards.
Yuki Tao
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
50 Points
182 Posts
Re: Jquery hide a div when radio button is checked resets to show when IE browser refreshes
Mar 07, 2019 11:45 AM|denkyira|LINK
Hi Yuki
Thanks. I did used $.cookie as you suggested and is working perfectly well.