title: How can I store a selected radio button's text in localStorage?
body: <p>Can anyone help me how to set the radio button selected text in localStorage? Here is my code but I'm getting undefined value at every time:           </p>
  
  <pre><code>&lt;label for="gender"&gt;GENDER:  
  &lt;input type="radio" id="radiobtn1" name="gender" value="0"/&gt;  
  &lt;label for="radiobtn1"&gt;MALE&lt;/label&gt;  
  &lt;input type="radio" id="radiobtn1" name="gender" value="1"/&gt;
  &lt;label for="radiobtn1"&gt;FEMALE&lt;/label&gt;  
  &lt;/label&gt; 
  &lt;br&gt;
  </code></pre>
  
  <p>jQuery code; I'm getting selected value when trying to write the code like this:</p>
  
  <pre><code>var tempgender = $("input:checked + label").text(); 
  console.log("gender selcte value:" + tempgender);
  </code></pre>
  
  <p>But when trying to save selected value in localstorage by writing this code then getting "undefined value".</p>
  
  <pre><code>window.localStorage.setItem("tempgender",$("input:checked + label").text());`                                                  
  </code></pre>
  
  <p>What am I doing wrong?</p>