Does not perform operations

0

How do I style bold to any text from Javascript ?

window.addEventListener("DOMContentLoaded",()=>{
var iLabel = document.getElementById('labelamodificar');
iLabel.style.fontWeight = "900";
});
<label id="labelamodificar" for="labelf">Nombre Usuario: </label>
<input type="text" id="labelf">

For example this works, but what I need is to give you the \<b> tag as if you had put it in the HTML .

    
asked by Eduardo Sebastian 21.09.2017 в 03:29
source

1 answer

1

Just remember to use class instead of id if you are going to change multiple label

document.querySelectorAll('.labelamodificar').forEach(function(elemento) {
    elemento.innerHTML = '<b>' + elemento.innerHTML + '</b>';
});

JSBin

    
answered by 21.09.2017 / 03:45
source