You need to use Javascript for this. As the attribute for
points to the id
of input
, you can change the placeholder
field picking up the text from label
where the for
of the first is equal to id
of the second.
The code below will go through all label
, take the value of for
, search for an element that has the id
equal to the value of for
and apply the placeholder
with the text of label
:
const labels = document.querySelectorAll("label[for]")
for(let i of labels){
let el = document.getElementById(i.getAttribute("for"));
if(el) el.placeholder = i.textContent;
}
<label for="sing_pass" class="label_pass"><span class="lang" key ="Text33">Code Activation</span></label>
<input type="text" id="sing_pass" class="input">
<label for="teste" class="label_pass"><span class="lang" key ="Text33">Qualquer coisa</span></label>
<input type="text" id="teste" class="input">
If it’s just one element, it’s simpler:
document.getElementById("sing_pass")
.placeholder = document.querySelector("[for='sing_pass']").textContent;
<label for="sing_pass" class="label_pass"><span class="lang" key ="Text33">Code Activation</span></label>
<input type="text" id="sing_pass" class="input">
Only with Html, impossible, need Javascript for this.
– LeAndrade