lundi 31 juillet 2017

Show on 'checked'

Explain me please what's wrong with this example: http://ift.tt/2hh4XXk

<label id="formSecondPhone"><input type="checkbox" name="secondContact" value="1"> Phone</label> 
<label id="formSecondPhoneField" class="form-item">Enter your number: <input type="number" name="secondPhone"></label>

#formSecondPhoneField { display: none; }

$('label#formSecondPhone:first-child').change(function() {
    var id = $('#formSecondPhoneField');
    $(this).attr('checked') ? $(id).show() : $(id).hide();
});

It's just add display:none; to my field and do nothing else, but i need a toggle effect.




Aucun commentaire:

Enregistrer un commentaire