Skip to main content
ubuntuask.com

Back to all posts

How to Use Onclick Method Inside Aem Component?

Published on
3 min read
How to Use Onclick Method Inside Aem Component? image

Best AEM Development Tools to Buy in October 2025

1 AEM 30-0300 X-Series Wideband UEGO AFR Sensor Controller Gauge

AEM 30-0300 X-Series Wideband UEGO AFR Sensor Controller Gauge

  • MODERN DESIGN WITH 87% LARGER DISPLAY FOR BETTER VISIBILITY.

  • ADVANCED X-DIGITAL WIDEBAND TECH FOR OPTIMAL ENGINE TUNING.

  • FASTER RESPONSE TIMES ENSURE SAFER, MORE POWERFUL ENGINE PERFORMANCE.

BUY & SAVE
$185.75 $217.95
Save 15%
AEM 30-0300 X-Series Wideband UEGO AFR Sensor Controller Gauge
2 AEM 30-0311 X-Series OBDII Gauge

AEM 30-0311 X-Series OBDII Gauge

  • READS DTCS FOR 2008+ VEHICLES VIA OBDII – EFFORTLESS DIAGNOSTICS!
  • SLIM DESIGN ALLOWS VERSATILE MOUNTING – FITS ANYWHERE!
  • AUTO-DIMMING SENSOR ENSURES CLEAR VISIBILITY UNDER ALL CONDITIONS!
BUY & SAVE
$169.94
AEM 30-0311 X-Series OBDII Gauge
3 AEM 30-0306 X-Series Boost Pressure Gauge 52mm, Black

AEM 30-0306 X-Series Boost Pressure Gauge 52mm, Black

  • ACCURATE READINGS FOR RELIABLE PERFORMANCE MONITORING.
  • EASY INSTALLATION FOR A HASSLE-FREE SETUP PROCESS.
  • SLEEK DESIGN ENHANCES DASHBOARD AESTHETICS AND FUNCTIONALITY.
BUY & SAVE
$190.00 $217.95
Save 13%
AEM 30-0306 X-Series Boost Pressure Gauge 52mm, Black
4 AEM 30-2056 12 Position Universal Trim Pot

AEM 30-2056 12 Position Universal Trim Pot

  • WEATHERPROOF DESIGN ENSURES DURABILITY IN ANY ENVIRONMENT.
  • COLOR-CODED WIRES SIMPLIFY INSTALLATION AND REDUCE ERRORS.
  • EASY MOUNTING WITH A 3/8 HOLE AND SIMPLE WRENCH TIGHTENING.
BUY & SAVE
$29.99 $37.99
Save 21%
AEM 30-2056 12 Position Universal Trim Pot
5 AEM 30-4110NS Digital Wideband UEGO Gauge without Sensor , Black , 6.025 inches

AEM 30-4110NS Digital Wideband UEGO Gauge without Sensor , Black , 6.025 inches

  • COMPLETE SET: GAUGE, HARDWARE, AND WELD-IN BUNG INCLUDED!
  • DUAL FACEPLATE OPTIONS FOR A CUSTOM LOOK TO SUIT ANY STYLE.
  • RS232 OUTPUT FOR SEAMLESS INTEGRATION WITH YOUR SYSTEMS.
BUY & SAVE
$149.95
AEM 30-4110NS Digital Wideband UEGO Gauge without Sensor , Black , 6.025 inches
6 AEM 30-0301 X-Series Pressure Gauge, Black, 52mm

AEM 30-0301 X-Series Pressure Gauge, Black, 52mm

  • PRECISION READINGS FOR OPTIMAL ENGINE PERFORMANCE MONITORING.
  • SLEEK DESIGN ENHANCES INTERIOR AESTHETICS WHILE PROVIDING FUNCTION.
  • EASY INSTALLATION WITH UNIVERSAL COMPATIBILITY FOR VARIOUS VEHICLES.
BUY & SAVE
$192.45 $217.95
Save 12%
AEM 30-0301 X-Series Pressure Gauge, Black, 52mm
7 AEM 52mm Wideband UEGO Air Fuel Ratio Sensor Controller Gauge w/White Face Kit

AEM 52mm Wideband UEGO Air Fuel Ratio Sensor Controller Gauge w/White Face Kit

BUY & SAVE
$211.98
AEM 52mm Wideband UEGO Air Fuel Ratio Sensor Controller Gauge w/White Face Kit
8 AEM 30-4406 -30-35 PSI Boost Gauge

AEM 30-4406 -30-35 PSI Boost Gauge

  • DURABLE HIGH-CARBON STEEL FOR LONG-LASTING PERFORMANCE.
  • VERSATILE: CUTS, STRIPS, AND CRIMPS 10-22 GAUGE AUTOMOTIVE WIRES.
  • CRIMPS BOTH INSULATED AND NON-INSULATED IGNITION TERMINALS EASILY.
BUY & SAVE
$164.25 $180.64
Save 9%
AEM 30-4406 -30-35 PSI Boost Gauge
+
ONE MORE?

To use the onclick method inside an AEM component, you can add an onclick attribute to the HTML element that you want to trigger the onclick event. Within this attribute, you can specify the JavaScript function that should be executed when the element is clicked. This function can be defined either inline within the onclick attribute or externally in a separate JavaScript file. When the element is clicked, the specified function will be triggered, allowing you to perform any desired actions or manipulations within your AEM component.

What is event delegation in onclick method in AEM components?

Event delegation in onclick method refers to the process of attaching a single event handler to a parent element that will fire for all descendants matching a selector, instead of attaching multiple handlers to each individual element. This is often used in AEM components to handle click events on multiple elements within a component without having to attach a separate onclick handler to each element.

By using event delegation, you can improve performance and reduce the amount of code needed to handle events in AEM components. This is especially useful when dealing with dynamic content or when there are multiple elements that need to trigger the same action.

How to pass event parameters in onclick in AEM components?

To pass event parameters in the onclick event in AEM components, you can add a JavaScript function that takes the event as a parameter and then access the event properties.

Here's an example of how you can achieve this:

  1. Create a JavaScript function that takes the event as a parameter and accesses its properties:

function handleClick(event) { console.log("Event target: ", event.target); console.log("Event type: ", event.type); // Add more parameters as needed }

  1. In your AEM component, add an onclick attribute to the HTML element and pass the event parameter to the handleClick function:

Click me

  1. When the button is clicked, the handleClick function will be called with the event as a parameter, and you can access its properties as needed.

By following these steps, you can pass event parameters in the onclick event in AEM components.

How to trigger a function using onclick in AEM?

To trigger a function using onclick in AEM, you can follow these steps:

  1. Add a button or element with an onclick attribute to your AEM page. For example:

Click me

  1. Define your function in a script tag on the same page or in an external JavaScript file. For example:
  1. Save and publish your AEM page to see the button on the published site. When the button is clicked, the myFunction() will be triggered.