In a Lightning Component I have

<div style="border: green solid 3px;" onclick="console.log(123);">

As far as I see, the old-school events do not work. What is the easiest way to get a click-event on a div?


Inline Javascript is not supported due to security threat and you can simply use onclick event and always follow the Unobtrusive principles.You can look at document here which mentions to avoid inline script

Try below code

 <div style="border: green solid 3px;" onclick="{!c.logData}">

The controller code

   logData : function( cmp, evt,  h ){

I believe the name of the event is onclick instead of click. I think you can bind your controller method to onclick by specifying a method.

Example: <div onclick='{!c.handle}' >Hello<div>

  • I fixed that, thanks. But my real issue is addressed by @MohithSrivastava – Uwe Heim Dec 22 '16 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.