Input "step" is only working on first change of input

222 views Asked by At

I am attempting to change the value of a cart input by increments of 5. I set the value of the 'step' input to 5 with the following code. I would like the input to start at 5 and only go up in increments of 5.

setTimeout(function() {
  var input = document.getElementById("__BVID__7");
  console.log(input);
  input.setAttribute("min" , "5");
  input.value = 5;
  input.setAttribute("step","5");
}, 2000);

The first click up on the input behaves correctly and the value jumps from 5 to 10. However after that the 'step' reverts back to 1 and the values go to 11, 12, 13, etc.

FYI, I have the timeout function set to give the page time to load before I grab the ID. The input I am trying to manipulate is loaded in an iframe.

0

There are 0 answers