mercredi 30 mai 2018

How to write a general height-altering javascript function

You can write something like

function changeHeight() {
    document.getElementById('chartdiv').style.height = "200px"
}
<button type="button" onClick="changeHeight();"> Click Me!</button>

But if you would have a second div with the same id and a button it would still alter the height of the first element when pressing the second button. Is it possible to write a more general method that you can apply on all elements?




Aucun commentaire:

Enregistrer un commentaire