Without using JQuery how would I convert
$('#H10 option[value*="2"]').attr('selected',true).trigger('change')
into vanilla Javascript. I believe using dispatchEvent(new Event('')) would replace trigger() but I cant find anything for the attr() function. When I tried to use :
document.querySelector('#H10 option[value*="2"]').setAttribute('selected', 'selected').dispatchEvent(new Event('change'))
I get Uncaught TypeError: Cannot read properties of undefined (reading 'dispatchEvent'). Other things I have tried include using the selected() = true.
Any help appreciated.