JS-like actions and events in AMP
AMP supports actions and events to all elements. For example, if you want to play a video when you press a button, you will use an action and event. Here is an example:
Clicking on the “Play” button will magically make the video with the ID of “myVideo” to play. The way it works is, that first we use the AMP universal event called
tap. Every HTML and AMP element supports this event. Next we use the ID of the element we want to manipulate, in our case, the video. And finally we tell it the action we want the element to perform once pressed or tapped.
Different elements support different events and actions. Obviously the
<p> element doesn’t support the
play action but
amp-video does support it. The AMP docs lists all the actions and events supported by elements