Goal: Apply action to each checked element if checked, vs just the one element.
I am setting up multiple buttons (custom components) that when clicked, the border changes for the
tag within . When clicked again, the border resets.
I have 'checked' properly displaying when I click on the flash-card-check-mark (elm), however my code is only selecting the first item and ignoring the rest.
Can you point me in the right direction as to how I would go about making sure that -- any -- of the buttons being clicked will have this action applied?
(new to javascript and appreciate your insight)
Note: This is for code example (doesn't run without the component checked but shows the markup I'm using -- I would share a link but this is running locally)
document.querySelector('flash-card-check-mark').onclick = function() {
var elem = document.querySelector('flash-card-check-mark');
var elemContent = document.querySelector('flash-card-check-mark p');
if (elem.getAttribute("checked") === null) {
elemContent.style.border = "1px solid #0000";
} else {
elemContent.style.border = "1px solid magenta";
}
};
<flash-card-check-mark no-default-padding="true">
<p align="left" size="small" class="pa-2">
<span slot="heading">Start my marketing today</span>
</p>
</flash-card-check-mark>
<flash-card-check-mark no-default-padding="true">
<p align="left" size="small" class="pa-2">
<span slot="heading">Create automated customer journeys</span>
</p>
</flash-card-check-mark>