0

I have a dynamically generated Button element in my HTML that does a refresh:

<button id="b4545" type="button" onclick="ae(1657,1693,10,event.target);" title="Refresh the data">Refresh</button>

I would like to call the onclick event that it dynamically generates from a routine that has nothing to do with the actual mouse click event.

Is it possible to (for instance) get a reference to the button via the id (which is known) and then fish out the JS from the onclick event - and then call it?

OR - can I generate a fake onclick event for that Button?

Any ideas?

Scott Savage
  • 373
  • 1
  • 4
  • 17
  • That may be the only way to go, but I know that JS has strange and useful capabilities. I was just hoping that there was a way to just "click" the button from code. – Scott Savage Dec 02 '18 at 17:19

2 Answers2

1

For dynamically generated buttons you can use for example

$("#myButtonId").trigger("click");

over the element

John
  • 1,711
  • 2
  • 29
  • 42
-1

You can trigger the onClick event. If you are using jquery use

$(#btnId).trigger()
Hari Prathap
  • 102
  • 7