Answer the question
In order to leave comments, you need to log in
How to change reactjs input value?
It is necessary to execute js code from the chrome console (without any react debuggers) that will change the value of a certain field. The application is written in react.
Here is a similar question 4answered.com/questions/view/242e0e3/reactjs-chang...
I would like to change the values with javascript/jquery but when I hit submit, the old initial values are used and not my new ones.
I cannot change the react code, I can only change the values with javascript/jquery as shown below.
var value = "randomIntValue"; $("input[data-reactid='.0.2.0.0.0.0.0.2.0.0.3.0.3.0.0']").val(value).change();
The above code doesn't work!
const changeValue = (element, value) => {
const event = new Event('input', { bubbles: true })
element.value = value
element.dispatchEvent(event)
}
var someElement = document.querySelector(".text-input");
changeValue(someElement, 200)
Answer the question
In order to leave comments, you need to log in
1) change exactly the same as not in react.
var a = document.getElementById("name");
a.value = "some value";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question