Fair warning:
element.onclick()
does not behave as expected. It only runs the code within onclick="" attribute
, but does not trigger default behavior.
I had similar issue with radio button not setting to checked, even though onclick
custom function was running fine. Had to add radio.checked = "true";
to set it. Probably the same goes and for other elements (after a.onclick()
there should be also window.location.href = "url";
)