UI How to apply OnClick handler for button which generated from hierarchy (IDE)?

I’m a very fresh beginner in Unity.

I have read through some important documentation but i still can’t understand some part.

Example :
If I created a button which is a child of Canvas. and i have named the button as “Play”.
So, how do i use script to get the button UI along with its ID(Play) , then how to use it on Addlistener onclick too ?

Any example can guide me in JavaScript way ?

Here tutorial for your question :

Create C# or Java script file and add any of the gameobject in scene(or simply add to Main camera).

Click the ‘+’ symbol on On click() in button and add gameobject(or Main camera) to the gameobject in
On click().

Create the public function in script which has created.

press No Function button on Click(),which shows the name of script which added to the gameobject(or Main camera) and select the global function which display on list.

During Runtime if click the button,the function which has added to On Click() will be called.