My script has error Uncaught TypeError: Cannot set property 'value' of null
I want to set value to input
let engine = document.querySelector('select[name=butterbean_stm_car_manager_setting_engine]');
engine.value = "0";
How can I fix this?
HTML:
<input type="text" value name="butterbean_stm_car_manager_setting_engine" class="widefat">
I dont think that the selector works, since you are selecting a select
tag even though you want to grap the input
tag. So maybe try
let engine = document.querySelector('input[name=butterbean_stm_car_manager_setting_engine]
instead. Though personally I would just target it with the widefat
class instead since its shorter
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.