Js加载页面更改输入最小值

时间:2018-12-29 19:17:11

标签: javascript html input

我想通过js onload indde.ut最小值更改。

我正在尝试此代码,但无法正常工作。

<script type="text/javascript">$(document).ready(function(){
    $("#quantity_5c27c535d66fc").min('10');
});</script>

我的输入代码;

<input type="number" id="quantity_5c27c535d66fc" class="input-text qty text" step="10" min="1" max="" name="quantity" value="1" title="Miktar" size="4" pattern="[0-9]*" inputmode="numeric" aria-labelledby="">

最小值更改等5

2 个答案:

答案 0 :(得分:2)

尝试一下:

<script type="text/javascript">
  $(document).ready(function(){ 
    $("#quantity_5c27c535d66fc").min=10;
  });
</script>

我希望这会有所帮助!

答案 1 :(得分:2)

对我来说,可行的解决方案是:

$(document).ready(function() {
    $('#quantity_5c27c535d66fc').attr({
       'min': 2,
    });
});

jQuery在这里使用attr函数,使用了一些不同的方法。