locked
Jquery hide a div when radio button is checked resets to show when IE browser refreshes RRS feed

  • Question

  • User457850011 posted

    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>

    Tuesday, March 5, 2019 8:15 PM

Answers

  • User1520731567 posted

    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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 6, 2019 6:11 AM

All replies

  • User475983607 posted

    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>

    Store the state of the div in a database table, Session, or Cookie.

    Tuesday, March 5, 2019 8:47 PM
  • User1520731567 posted

    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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 6, 2019 6:11 AM
  • User457850011 posted

    Hi Yuki

    Thanks. I did used $.cookie as you suggested and is working perfectly well.

    Thursday, March 7, 2019 11:45 AM