javascript - on text input focus explaining label appears -
basically need on text input focus explaining bar (what input does) needs appear (animation) text input bottom. have hard time figuring out, way in css or javascript, love hear guys explanations, ill upload mess code. seen solutions, form has lot of labels , lot of going on, super confusing, im pretty new @ also. here code:
<div class="form-row"> <input type="text" name="firstname" id="nickas" class="input-text" placeholder="enter name:"> <label for="nickas">user name:</label> <label class="label-helper" for="nickas">this bar appears</label> </div>
set additional class has opacity of 0 .label-helper
, , toggle class using jquery's focus
, blur
events:
$('input').on('focus', function() { $(this).siblings('.label-helper').addclass('in'); }).on('blur', function() { $(this).siblings('.label-helper').removeclass('in'); });
.label-helper { opacity: 0; -webkit-transition: opacity .2s ease; -moz-transition: opacity .2s ease; transition: opacity .2s ease; } .label-helper.in { opacity: 1; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="form-row"> <input type="text" name="firstname" id="nickas" class="input-text" placeholder="enter name:"> <label for="nickas">user name:</label> <label class="label-helper" for="nickas">this bar appears</label> </div>
Comments
Post a Comment