+ Start a Discussion
Leticia Monteiro Freitas 4Leticia Monteiro Freitas 4 

Using image as link

I'm trying to use a image inside a table, and when I click on it, should call a function an pass a parameter. But when I use the tag<img> inside the tag<a> the parameter is set as null. 

Could anyone help me?
!--- comp
 <a  data-ex="{!contSubIndex}" onclick="{!c.expandTVSubTable}">
                                                                                            <img src="{!$Resource.v360IconeMais}"/>
 
                                                                                       </a>
Controller

 
var index = event.target.getAttribute('data-ex');
        alert(index);
Naveen IlaNaveen Ila

Here the event soruce is image actually. 

Change your code to like below to get the value of data-ex

<img data-ex="{!contSubIndex}" src="{!$Resource.v360IconeMais}"/>
 

 

Naveen IlaNaveen Ila
Does this answer solved your problem ?