Change HTML Attribute Value using JavaScript

preview_player
Показать описание

In this tutorial we will see how to Change HTML Attribute Value using JavaScript. setAttribute() method is used for this purpose which adds or updates the element's attribute.

#attribute #javascript #value
Рекомендации по теме
Комментарии
Автор

Can I also just say that the attribute shall be a javascript variable
Like
<script>
Var x = '50'
</script>
<p id="x">Hello</p>

I guess it wont work in that way but can that work similarly?
And if yes, is that also possible for css like
.class {
width: x;
}

Sorry for the stupid question, i am a beginner 😅

Hallo