title: How can i get the value of a selected radio button on page load and then pass it inside a div using jquery?
body: <p>I have 2 radio buttons with one of them checked by default. I want firstly to get the default selected/checked value of the radio button and pass it in a specific div. After that i need to change the value of the div every time the radio buttons are clicked/selected.</p>
  
  <p>Below is my code but it doesn't work as it should as the <code>$('input[name="price"]:selected').val();</code> return <code>undefined</code>
  What i am doing wrong?</p>
  
  <p>Here is my code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function calculate(prc) {
  $(".popup-total-price").text(prc.value + "€");
  }
  
  
  var pricepopup=$('input[name="price"]:selected').val();
  $(".popup-total-price").html("&lt;span&gt;&lt;/span&gt;" + pricepopup + "€" );</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.popup-item-size-title {
    display: inline-block;
  }
  
  .popup-total-price {
    color: red;
    margin-top: 20px;
  
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;label class="popup-item-label ripple"&gt;
  &lt;input value="81.00" class="pp-rr" onclick="calculate(this);" type="radio" name="price" id="price" checked="checked"&gt;
  &lt;div class="popup-item-size-title"&gt;81.00€&lt;/div&gt;                                  &lt;/label&gt;
  
  &lt;label class="popup-item-label ripple"&gt;
  &lt;input value="50.00" class="pp-rr" onclick="calculate(this);" type="radio" name="price" id="price"&gt;
  &lt;div class="popup-item-size-title"&gt;50.00€&lt;/div&gt;                                  &lt;/label&gt;
  
  
  &lt;div class="popup-total-price"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>