How to hide the text and its radio button, jquery?

0

I have these 3 radio buttons:

<ul>
  <li>
    <label class="label-radio item-content">
      <input type="radio" name="entregaPedido" value="2">
      <span class="item-media">
        <i class="icon icon-form-radio"></i>
      </span>
      <span class="item-inner">
        <span class="item-title">Recoger en Centro de Negocio</span>
      </span>
    </label>
  </li>
  <li>
    <label class="label-radio item-content">
      <input type="radio" name="entregaPedido" value="1" checked>
      <span class="item-media">
        <i class="icon icon-form-radio"></i>
      </span>
      <span class="item-inner">
        <span class="item-title">Envío a Domicilio Normal</span>
      </span>
    </label>
  </li>
  <li id="sucursalesCorreos">
    <label class="label-radio item-content">
      <input type="radio" name="entregaPedido" value="1">
      <span class="item-media">
        <i class="icon icon-form-radio"></i>
      </span>
      <span class="item-inner">
        <span class="item-title">Entregar en Sucursal de Correos</span>
      </span>
    </label>
  </li>
</ul>

But I must perform a validation that allows me to hide or show the <li> that has the text Sent to Normal Home

That is, there will be a variable Cod_emp that if it is equal to 5 it should be hidden otherwise show.

    
asked by JG_GJ 08.11.2018 в 23:05
source

2 answers

1

I do not know if you mean this but we're going there. What I have understood is that if the employee is number 5, he does not show the list, on the contrary, he shows it. Here is the code This is a simple example with a button that checks the value of the input. If it is different from 5, it shows it, otherwise it hides it. I do not know if it's enough to give you an idea of how you can do it.

$(document).ready(function(){
  $("#boton").on('click',function(){
		var prueba1 = $("#input").val();
      if(prueba1 != 5){
        $("#sucursalesCorreos").show();
      }else
      {
        $("#sucursalesCorreos").hide();
      }
	});
});
#sucursalesCorreos{
  width:200px;
  height:50px;
  text-align:center;
  color:white;
  background-color: rgb(159, 143, 241);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="input" type="text" value="">
<button id="boton">Click</button>

<div id="sucursalesCorreos">Div a esconder</div>
    
answered by 29.11.2018 в 15:23
0

you only change your value or Cod and it is hidden or displayed

var Cod=4;
if(Cod===5){
  $("#envio_DN").css('visibility', 'visible');
}
else{
  $("#envio_DN").css('visibility', 'hidden');
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul>
  <li>lista1</li>
  <li id="envio_DN">
    <label class="label-radio item-content">
      <input type="radio" name="entregaPedido" value="1" checked>
      <span class="item-media">
        <i class="icon icon-form-radio"></i>
      </span>
      <span class="item-inner">
      <span class="item-title">Envío a Domicilio Normal</span>
      </span>
    </label>
  </li>
  <li>lista3</li>
</ul>
    
answered by 29.11.2018 в 15:45