I have this javascript code :
<input class="inp " type="text" value="0.01" inputmode="numeric">
I want to change the attribute value but nothing i tried worked . I tried this metrods :
document.getElementsByClassName("inp")[0].value=0.02;
document.getElementsByClassName("inp")[0].setAttribute("value","0.02");
document.querySelector("input.inp").value=0.02;
None of these seem to work they just change the value on the surface or the hud but when i try to use the changed value its always the value before i made the changes.
Am i doing something wrong or the site just restricts the changes of that attribute ?
You have a strong misconception here. Your code works fine, the problem is your expectations when modifying the value attribute.
The value attribute (as opposed to the value property!) serves only a single purpose: Declaratively defining the initial value in the HTML. With any Javascript you typically never interact with the value attribute.
Changing it later will not change the displayed value (but it will change el.defaultValue), nor will changing the value by interacting with the element update the attribute.
const el = document.querySelector("input.inp");
console.log(`el.value: ${el.value}, <input value="${el.getAttribute('value')}">, el.defaultValue: ${el.defaultValue}`);
el.value=0.33;
console.log(`el.value: ${el.value}, <input value="${el.getAttribute('value')}">, el.defaultValue: ${el.defaultValue}`);
el.setAttribute("value","0.66");
console.log(`el.value: ${el.value}, <input value="${el.getAttribute('value')}">, el.defaultValue: ${el.defaultValue}`);
<input class="inp" type="text" value="0.01">
After testing your code, it works correctly, your issue seems to be outside of the code.
document.getElementsByClassName("inp1")[0].value=0.02;
document.getElementsByClassName("inp2")[0].setAttribute("value","0.02");
document.querySelector("input.inp3").value=0.02;
<input class="inp1" type="text" value="0.01" inputmode="numeric">
<input class="inp2" type="text" value="0.01" inputmode="numeric">
<input class="inp3" type="text" value="0.01" inputmode="numeric">