Hi I have an input form and I also have some labels which will help a user to fill out the form. My css is set to hide these by default but when the user clicks on focus's on the input field then the next label will show and on blur it will be hidden.
With the current script I have written for some reason it keeps showing all the labels and it doesn't seem to hide it on blur.
Not an expert on jQuery so if any could help me fix this problem that would great.
My code is below or view a jsFiddle:
js/js.js
$(document).ready(function(){
$('.form-control').bind('blur', function(){
$('.form_helper').removeClass("form_helper_show").addClass('.form_helper'); });
$('.form-control').bind('focus', function(){
$('.form_helper').removeClass("form_helper").addClass('form_helper_show'); });
});
css/style.css
ul {
list-style:none;
}
li:nth-child(2), li:nth-child(3) {
display:inline;
}
.form_helper {
display:none;
}
.form_helper_show {
display:inline-block;
}
index.html
<div class="form-group">
<ul class="form_group">
<li><label for="client_name">Company Name</label></li>
<li><input class="form-control" name="client_name" type="text" id="client_name"/></li>
<li><label for="client_name_helper" class="form_helper">Input your clients name</label></li>
</ul>
</div>
<div class="form-group">
<ul class="form_group">
<li><label for="client_name">Company Code</label></li>
<li><input class="form-control" name="client_name" type="text" id="client_name"/></li>
<li><label for="client_name_helper" class="form_helper">Input your clients code</label></li>
</ul>
</div>