Input radio checking

Viewed 26

I'm trying to set the Input called iva displayed only when #azienda is selected but i don't understand why the code just doesn't set the display to block This is the code:

<style>
    .iva {
        display: none;
    }

    #azienda:checked~#iva {
        display: block;
    }
</style>
 

 <div class="rad">
        <input type="radio" id="azienda" name="radio" value="Azienda/Impresa/Società">
        <label for="azienda"> Azienda/Impresa/Società </label>

 </div>
 <input type="number" class="iva" name="iva" id="iva" placeholder="Inserire P.IVA...">

I'll give an hug at everyone who will help me please

1 Answers

You swiched from class to id with iva :)

<style>
    .iva {
        display: none;
    }

    #azienda:checked ~ .iva {
        display: block;
    }
</style>
 

 <div class="rad">
        <input type="radio" id="azienda" name="radio" value="Azienda/Impresa/Società">
        <label for="azienda"> Azienda/Impresa/Società </label>
 <input type="number" class="iva" name="iva" id="iva" placeholder="Inserire P.IVA...">
 </div>

Related