[英]for input type="number" how to set default value to 0
[英]Set default value for arrows in input[number]
我有一个input type="number"
用于选择应该加载为空的年份:
<input type="number" placeholder="Select year" min="1930" max="2015" required
ng-custom-mask="9999" />
当用户通过箭头键选择年份时,它从min
开始:1930。它会像 1980 一样。
如何将自定义“开始”编号设置为 input[number]?
(任何 HTML5、JavaScript(甚至 AngularJS)都会很好......)
怎么样:
HTML:
<input
type="number"
placeholder="Select year"
min="1930"
max="2015"
required
ng-custom-mask="9999"
ng-model="points"
step="{{getStep()}}" />
在您的控制器中:
$scope.getStep = function() {
if (!$scope.points) {
return 50;
}
return 1;
}
你可以只添加一个值属性
<input type="number" placeholder="Select year"
min="1930" max="2015" required ng-custom-mask="9999" value="1980"/>
我有点晚了,但这可以通过解决方法“解决”:
IE
HMTL:
<input type="number" placeholder="Select year" min="1980" max="1980" required ng-custom-mask="9999" />
查询:
$("input[type=number]").on("change", function(){
if ($(this).attr("min") == $(this).attr("max") && $(this).attr("min") == 1980) {
$(this).attr("min", 1930);
$(this).attr("max", 2015);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.