1

I am writing a Tampermonkey script to add more functionality to an existing website and I am trying to click on a button with the following source code:

<label _ngcontent-c10="" ngbbuttonlabel="" class="btn btn-agree ng-star-inserted">
      <input _ngcontent-c10="" ngbbutton="" type="radio" value="AGREE" ng-reflect-value="AGREE" name="decision">YES 
</label>

The input radio button is hiding behind a parent Label element.

I have tried clicking on the radio button using: radio_element.click() (where radio_element is that particular button) but that simply changes the state to active. radio_element.checked = true does not seem to work either.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
The Sage
  • 93
  • 1
  • 1
  • 4
  • Depending on how the event handlers are bound you most likely need to set the `checked` state of the radio, then trigger a `change` event on it – Rory McCrossan Jul 06 '21 at 10:39
  • What event would I have to pass through the change function? – The Sage Jul 06 '21 at 10:49
  • As stated by both Rory and Brian, the solution was to dispatch a 'change' event. https://stackoverflow.com/questions/2856513/how-can-i-trigger-an-onchange-event-manually/23612498#23612498 – The Sage Jul 08 '21 at 09:54

0 Answers0