#javascript #css #styling
#javascript #css #стиль
Вопрос:
Я не понимаю, почему атрибуты не устанавливаются в переменную
, почему цвет не меняется?
Вот код :
var text = document.createElement('h2');
text.textContent = 'TEXT';
text.setAttribute("style", "color: red, margin-top:5px");
document.body.appendChild(text);
Ответ №1:
Изменить color: red, margin-top:5px
на color: red; margin-top:5px
var text = document.createElement('h2');
text.textContent = 'TEXT';
text.setAttribute("style", "color: red; margin-top:5px");
document.body.appendChild(text);