Вход

Просмотр полной версии : Изменить значение атрибута style


Scheme
13.03.2017, 09:07
Как изменить значение атрибута style="opacity: 0; height: 20px;" в теге textarea. Именно Javascript-ом.

<textarea class="text-input" spellcheck="false" style="opacity: 0; height: 20px;" wrap="off"></textarea>

Все, что удалось нарыть:

<div>Button</div>

<script>
var div = document.body.children[0];
div.style.cssText="
opacity: 0; \
height: 20px; \
";

alert(div.style.cssText);
</script>

ksa
13.03.2017, 09:13
Scheme, у каждого ЦСС-свойства есть аналог - ДОМ-свойство элемента
opacity: 0;
div.style.opacity=0;
height: 20px;
div.style.height='20px';

Scheme
13.03.2017, 21:28
спасибо!