I have a lightning-button-icon with dynamic name and i want to update its selected attribute based on the name. Can someone tell me how can i do that?
my code (UPDATED):
<lightning-layout-item size="3">
<lightning-button-icon-stateful
data-class="slelectState"
data-index1={inx1}
data-index2={inx2}
data-id={pair.key}
name={pair.key}
icon-name="utility:check"
selected={selectState}
alternative-text="True"
onclick={handleSelect}>
</lightning-button-icon-stateful>
<lightning-button-icon-stateful
data-class="UnslelectState"
data-index1={inx1}
data-index2={inx2}
data-id={pair.key}
name={pair.key}
icon-name="utility:close"
selected={unSelectState}
alternative-text="False"
onclick={handleUnSelect}>
</lightning-button-icon-stateful>
</lightning-layout-item>
I tried this code this.template.querySelector(
[name="${selectedname}"])
as per @sfdcfox answer here but it gave me null value.