I'm trying to change the background color of the selected row in a table, but having some issues with it.
I'm trying to select the row and catch it with event, and later change the color for the event.target
a little help will be much appreciated.
this is my HTML:
<div class="products-row tableHeader">
<div class="products-cell" key={col.label} for:each={testColObj} for:item="col">{col.label}</div>
</div>
<div class="products-row" key={rowItem.Account.Id} for:each={testObjData} for:item="rowItem" data-id={rowItem.Account.Id}>
<div class="products-cell">
<input
type="radio"
name="selectedRow"
value={choseSelected}
id={rowItem.Account.Id}
onchange={changeChoose}/>
</div>
<div class="products-cell">
<span>{rowItem.Account.Id}</span>
</div>
<div class="products-cell">
<span>{rowItem.Account.Name}</span>
</div>
<div class="products-cell">
<span>{rowItem.Account.Industry}</span>
</div>
</div>
And my JS is:
changeChoose(event){
console.log(event.target.id);
this.choseSelected = event.target.id;
event.target.style.backgroundColor ='blue';
}
On the developer console, when I'm changing the products-row for the specific row in the HTML, it works, but I'm not sure how to apply it in the JS file.
Many thanks!