I have an existing Aura component that I need to add some help text to. I have a lightning:checkboxGroup
that I need to add some help text to one of the options. The code is below. What I need to do is add red text to the end of option2
. With Javascript I could start at the div surrounding the checkboxgroup and then navigate through the children to find the component then add <span style="color:red;">help text</span>
to the end of the label. Is there a way to do something the same using cmp.find
? I tried
<aura:component >
<aura:attribute name="options" type="List" default="[
{'label': 'Option1','value': 'Option1'},
{'label': 'Option2','value': 'Option2'},
{'label': 'Option3','value': 'Option3'},
]" />
<div aura:id="checkboxGroup" class="slds-col slds-size_1-of-1">
<lightning:checkboxGroup
name="checkbox"
label=""
options="{! v.options }"
value="{! v.checkboxValue }"
onchange="{! c.handleChange }"
class="slds-checkbox-horizontally"
/>
</div>
</aura:component>
handleChange : function (cmp, event, helper) {
//this returns an item but I can't find the children to get down to the label I need
var b = cmp.find("checkboxGroup");
console.log("*****b = " + b);
//this does not return anything
var a = Document.getElementByClass("slds-form-element__label");
console.log("*****a = " + a);
}
lightning
components provided by Salesforce - they are mostly lwc components now. Also, changevar a = Document.getElementByClass("slds-form-element__label");
tovar a = document.getElementByClassName("slds-form-element__label");
(case sensitivity, wrong name). If you do want to modify the internals of another component, you could use/adapt my component: github.com/rapsacnz/RadioGroup