I have a problem to keep the effect hover
, I look for when clicking that the image maintains the hover effect, and if I select the other image the effect of the first image is removed, and the second image maintains its hover effect . That works as a radio type input, in this case an image will remain selected.
<head>
<script type="text/javascript" src="js/jquery.min.js"></script>
<style>
.images1
{
width: 80px;
height: 80px;
background-image: url('icono/educacionp.png');
background-repeat: no-repeat;
cursor: pointer;
}
.images1:hover
{
background-image: url('icono/educacion.png');
cursor: pointer;
}
.clasehover
{
background-image: url('icono/educacion.png');
}
.images2
{
width: 80px;
height: 80px;
background-image: url('icono/Emprendimientop.png');
background-repeat: no-repeat;
}
.images2:hover
{
background-image: url('icono/Emprendimiento.png');
}
.clasehover2
{
background-image: url('icono/Emprendimiento.png');
}
.container{
margin: 0;
padding: 0;
list-style: none;
display: flex;
justify-content:center;
flex-wrap: wrap;
}
.container p{
margin-top:60px;
font-size: 12px;
cursor: pointer;
}
.imgicon{
display: flex;
justify-content: center;
cursor: pointer;
margin: 30px;
}
.textlarge{
display: flex;
}
.imgicon input{
margin-top: 55px;
margin-left: -30px;
}
</style>
</head>
<body>
<div class="container">
<div class="imgicon images1">
<label class="textlarge icono-educ">
<input type="radio" name="cajaradio" value="Educación" style="">
<p class="textradio">Educación</p>
</label>
</div>
<div class="imgicon images2">
<label class="textlarge icono-empren">
<input type="radio" name="cajaradio" value="Emprendimiento" style="">
<p class="textradio1">Emprendimiento</p>
</label>
</div>
</div>
<script>
$('input[type="radio"]').click(function(){
if ($(this).is(':checked'))
// var mensaje = $(this).val();
{
//alert("Seleccionaste: "+ mensaje);
if( $('.images1').hasClass('clasehover'))
{
$('.images1').removeClass('clasehover');
}
else{
$('.images1').addClass('clasehover');
}
}
});
</script>
</body>