Вы можете поцарапать идею «щелкнуть» и использовать «размытие» и «фокус».С моей идеей, ввод всегда будет возвращаться к обычному размеру, когда вы не сфокусированы на нем.
$(".input-style").focus(function() {
if ($(this).css('font-size') == '20px') {
$(this).animate({
fontSize: '15px'
});
} else {
$(this).animate({
fontSize: '20px'
});
}
});
$(".input-style").blur(function() {
if ($(this).css('font-size') == '20px') {
$(this).animate({
fontSize: '15px'
});
} else {
$(this).animate({
fontSize: '20px'
});
}
});
input {
margin-bottom:15px;
font-size:20px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" class="input-style">
<br>
<input type="text" class="input-style">
Однако, если вы хотите, чтобы он вернулся к своему обычному размеру строго при нажатии на другой ввод, это должно сделатьсделай это:
$(".input-style").click(function() {
if ($(this).css('font-size') == '20px') {
$(this).animate({
fontSize: '15px'
});
} else {
$(this).animate({
fontSize: '20px'
});
}
$("body").children().not(this).animate({
fontSize: '20px'
})
});
.input-style {
margin-bottom:15px;
font-size:20px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" class="input-style">
<br>
<input type="text" class="input-style">