I have a button in a table in lightning component. I'm trying to get clicked id of the record.
Component markup
<table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout">
<thead>
<tr class="slds-text-heading--label">
<th scope="col">
<div class="slds-truncate" title="Name">Name</div>
</th>
<th scope="col">
<div class="slds-truncate" title="Remove">Remove</div>
</th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.Items}" var="item">
<tr>
<td>
<div class="slds-truncate" title="{!item.Name}">{!item.Name}</div>
</td>
<td>
<form onclick="{!c.removeItem}">
<input type="hidden" class="prodclass" value="{!item.Id}" id="{!item.Id}" />
<lightning:button label="Remove" iconName="utility:delete" iconPosition="left" variant="destructive" value="{!item.Id}"/>
</form>
</td>
</tr>
</aura:iteration>
</tbody>
</table>
JS Controller
removeItem: function(component, event, helper) {
var id_str = event.target.getElementsByClassName('prodclass')[0].value;
console.log(id_str);
}
I'm getting error,
ElementsByClassName is not a function
Appreciate any help on this. Thanks.