Show hide problem on page load
Hello,
My form is not hidden on page load but the jquery code works perfectly as soon as I start clicking on the radial buttons.
After the page load, the form is visible even if the second radial has been set(via php) to "checked".
Do the change() even needs a manual change? Or does it only needs a "value" change?
- $(document).ready(function(){
- $('[name="radios"]').on('change', function() {
- var radio = $(this).val();
- if(radio == "delivery"){
- $("#delivery_address").fadeIn();
- }else{
- $("#delivery_address").hide();
- }
- }).change();//I have also tried without this event, same problem.
- });
- <div class="radio">
- <label for="radios-0">
- <input type="radio" name="radios" value="pickup" <?php echo $pickup; ?>>
- I want to <strong>pick up</strong> my order
- </label>
- </div>
- <div class="radio">
- <label for="radios-1">
- <input type="radio" name="radios" value="delivery" <?php echo $delivery; ?>>
- Please <strong>deliver</strong> the order to my delivery address
- </label>
- </div>
- <div id="delivery_address" style="display: none;">
- My form is here:
- </div|>
Thanks!