我找到了解决你问题的办法。如果您希望这样做,我建议您像这样更改代码。
记得:
您需要根据字体大小更改“7.5”。
<input id="value" type="text" value="..." size="1" readonly>
#value{
transition:width ease-in 500ms;
}
function refresh_price() {
$.ajax({
url:"query.php?currency=<?=$currencycode;?>"
}).done(function(data) {
$("value").attr("value", data).attr("size", data.length - 2);
$("#value").width((data.length * 7.5) );
});
}
refresh_price();
setInterval(refresh_price, 5000);
这就是例子。用这个只会得到想法。使用上面的代码块。这就是你想要的解决方案
var price=5000;
function refresh_price() {
var data="50000";
$("#value").attr("value", price).attr("size", price.length - 2);
$("#value").width((price.toString().length * 7.5) );
if(price==1220703125000){
price=5000;
}else{
price *= 5;
}
}
refresh_price();
setInterval(refresh_price, 5000);
#value{
transition:width ease-in-out 500ms;
}
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<input id="value" type="text" value="..." size="1" readonly>
或使用
Codepen Example