This is some HTML I have:
<label class="rlabel">First Name</label>
<input class="rinput" type="text" placeholder="Fisrt Name" required />
<label class="rlabel">Last Name</label>
<input class="rinput" type="text" placeholder="Last Name" />
Here is the CSS:
.rlabel{opacity:0; }
And now, some Jquery:
$('.rinput').focus(function(){
$(this).parent('.rlabel').css({'opacity':'1'});
})
My goal is to change the opacity to 1 of the parent class "rlabel" when focusing on this class "rinput" using jquery.
I've attempted the following:
$('.rinput').focus(function(){
$(this).parents('.rlabel').css({'opacity':'1'});
})
as well as:
$('.rinput').focus(function(){
$(this).parent('.rlabel').css({'opacity':'1'});
})
and also:
$('.rinput').focus(function(){
$(this).closest('.rlabel').css({'opacity':'1'});
})
and finally:
$('.rinput').focus(function(){
$(this).parents().css({'opacity':'1'});
})