JSFiddle - React, Tailwind, and code Playground

by Alexandru Mihai

HTML

<ul id="checkout-method">
    <li><input name="payment_method" type="radio" value="Cash on Delivery" id="Cash">
        <label for="Cash">Cash on Delivery</label>
        <p class="explainpaymethod" style="display:none">Pay with cash upon delivery.</p>
    </li>
    <li><input name="payment_method" type="radio" value="Paypal" id="Paypal">
        <label for="Paypal">Paypal</label>
        <p class="explainpaymethod" style="display:none">Pay via PayPal; you can pay with your credit card if you don’t have a PayPal account.</p>
    </li>
</ul>

JavaScript

$('input[type="radio"]').eq(0).prop('checked',true);
$('input[type="radio"]').eq(0).closest('li').find('.explainpaymethod').show();
$('#checkout-method input').change(function() {
  $('.explainpaymethod').hide();
  $(this).closest('li').find('.explainpaymethod').show();
});