I need event element to append div after this event element. With Locker Service. It's Working using jQuery before activation Locker Service. But now i am not getting event target element.

I want to display a div after a button click. I am using lightning.

Here is some code example:


<lightning:button variant="neutral" value="deleteMass" onclick="{!c.doSomething}" />

Component Controller

doSomething: function(cmp, event){
   var myButton = $(event.target).closest("button");

   // appending a div after that button
   var tabbedDiv = $(".tabular-dropdown");
  • There's no need to use jQuery here. Perhaps you could include some more code?
    – sfdcfox
    Commented Mar 6, 2017 at 8:47
  • Hope this helps. Commented Mar 6, 2017 at 9:19

1 Answer 1


DOM event not working in lightning component namespace (eg: lightning:button or ui:button)

I just put a unique Id in its parent And put a value tag in lightning:button eg:

<li id="1212__Button">
 <lightning:button variant="neutral" value="1212__Button" onclick="{!c.doSomething}" />

And then i got the value in controller using event.getSource() eg:

doSomething: function(cmp, event){
 var value = event.getSource().get("v.value");
 var targetBtn.append(tabbedDivHtml); = $('#'+ value);
 var tabbedDiv = $(".tabular-dropdown");

 // appending a div after that button
  • This answer for those who has enabled locker service
    – Tariq
    Commented Apr 14, 2017 at 7:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .