在 dom 元素值中使用 vanilla js 设置值不起作用
setting values with vanila js in dom element value is not working
here is a website https://secure.givelively.org/donate/lifesteps
我想在此处使用简单的 js/jquery 输入自定义值
当我们点击继续时它不起作用
我试过了
document.querySelector("#custom-input-element").click()
和
document.querySelector("#custom-input-element").focus()
和
document.querySelector("#custom-input-element").value='1';
全部无效
尝试
$('#custom-input-element').click(() => console.log(clicked));
我只是在我的机器上使用它来确保它能正常工作,或者确保 html id 没有拼错
let elem = document.getElementById("custom-input-element");
const prevVal = elem.value;
elem.value = 1;//Your Value
elem._valueTracker.setValue(prevVal);
let event = new Event("input", { target: elem, bubbles: true });
elem.dispatchEvent(event);
我试过了
document.querySelector("#custom-input-element").click()
和
document.querySelector("#custom-input-element").focus()
和
document.querySelector("#custom-input-element").value='1';
全部无效
尝试
$('#custom-input-element').click(() => console.log(clicked));
我只是在我的机器上使用它来确保它能正常工作,或者确保 html id 没有拼错
let elem = document.getElementById("custom-input-element");
const prevVal = elem.value;
elem.value = 1;//Your Value
elem._valueTracker.setValue(prevVal);
let event = new Event("input", { target: elem, bubbles: true });
elem.dispatchEvent(event);