<div class="data-list"> <template for:each={data} for:item="item"> <div key={item.code} class="data-item" data-code={item.code} data-name={item.name} data-volume={item.volume} onclick={handleItemClick}> <strong>{item.code}</strong><br />{item.name}<br />{item.volumeFormatted} </div> </template> </div> handleItemClick(event) { this.MCCObj = { code: event.currentTarget.dataset.code,//nome dos campos name: event.currentTarget.dataset.name, volume: event.currentTarget.dataset.volume } this.selectedMCC = this.MCCObj.code + ' - ' + this.MCCObj.name; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter