任务是,如果用户填写该字段,则输入字段中的提示将位于顶部,为此,如果输入的值已填写,我需要添加一个类:
.contacts-form {
padding: 32px 54px;
background: #fff;
box-shadow: 0 5px 18px 0 rgba(0, 0, 0, 0.05);
}
.ui-group {
position: relative;
}
.ui-field {
width: 100%;
height: 50px;
padding: 12px 0 0;
border: 0 solid #E1F5F2;
border: 0 solid #6BC5D2;
border-bottom-width: 1px;
background-color: #fff;
font-size: 15px;
color: #390050;
display: block;
transition: all .3s ease;
}
.ui-field:focus+.ui-placeholder {
margin-right: 0;
top: 0;
left: 0;
font-size: 13px;
}
.ui-placeholder {
margin-right: 4px;
top: 23px;
left: 0;
font-size: 14px;
color: #9B8EA0;
position: absolute;
transition: top .3s ease;
}
.ui-placeholder::before {
content: '*';
display: inline;
transition: all .3s ease;
}
<form action="#" class="contacts-form">
<div class="ui-group">
<input type="text" class="ui-field" id="name" value="">
<label for="name" class="ui-placeholder">Имя</label>
</div>
</form>
JS:
jQuery:如果我正确理解要添加哪个类..
可以这样吗