I am trying to change the placeholder "Company Name (optional) to "Child's Name".
I'm not able to edit the HTML directly, but I can use a JavaScript file. I'm trying to access the below HTML with a JavaScript file.
<div class="col-md-12">
<input class="not-required" id="company" name="company"
type="text" value="">
<label alt="Company Name (optional)" placeholder="Company Name (optional)"></label>
</div>
The code below adds "Child's Name" to the <input>, but I would like to add it to the <label> instead. The label does not have an id or class. Is there a way to change the label placeholder from "Company Name (optional) to "Child's Name"?
function myFunction() {
document.getElementById("company").placeholder = "Child's Name";
}
myFunction();
document.querySelector("#company + label").textContent = 'Child's Name';...which work with the existing markup.