I want to add style="font-weight: bold;"
to the label tag of the html below:
<label for="Results_CheckZ" style="font-weight: bold;">Sample content</label>
<div id="Results_CheckZField" class="field-normal both checkZ">
<div class="field-control">
<div class="container-normal">
<label for="Results_CheckZ">Sample content</label>
</div>
</div>
</div>
I tried the following but it didn’t work.
I don’t know how to get the label
tag when it doesn’t have an id
or class
.
If anyone has any advice I’d appreciate it. Thanks!
const targetLabel = document.querySelector('#Results_CheckZField .field-control .container-normal');
targetLabel.setAttribute("style", "font-weight: bold;");
2
Answers
Select the label tag directly within the container-normal class and then apply the style to it.
Select the tag and then use style attribute to add what ever css you want to apply