Css замена текста
Автор Петр Гудков задал вопрос в разделе JavaScript
Как изменить текст в теге div с помощью JS и получил лучший ответ
Ответ от - -[гуру]
Через редактирование свойство textContent.
Ответ от 657567654[гуру]
изменяй innerHTML его
изменяй innerHTML его
Ответ от Илья Ш[гуру]
document.getElementByID("mydiv").innerHTML = "New text!";
document.getElementByID("mydiv").innerHTML = "New text!";
Ответ от Николай Веселуха[гуру]
<!doctype html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Документ</title>
<script>
/*global window, document */
'use strict';
window.addEventListener('load', function () {
var rep = document.querySelector('#rep');
rep.addEventListener('click', function () {
var text, textNode;
text = document.querySelector('#text');
text.removeChild(text.firstChild);
textNode = document.createTextNode("Я тебя заменил! ");
text.appendChild(textNode);
this.style.display = 'none';
});
});
</script>
</head>
<body>
<div id="text">Замени меня!!! </div>
<button id="rep">Замени его! </button>
</body>
</html>
<!doctype html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Документ</title>
<script>
/*global window, document */
'use strict';
window.addEventListener('load', function () {
var rep = document.querySelector('#rep');
rep.addEventListener('click', function () {
var text, textNode;
text = document.querySelector('#text');
text.removeChild(text.firstChild);
textNode = document.createTextNode("Я тебя заменил! ");
text.appendChild(textNode);
this.style.display = 'none';
});
});
</script>
</head>
<body>
<div id="text">Замени меня!!! </div>
<button id="rep">Замени его! </button>
</body>
</html>
Ответ от 22 ответа[гуру]
Привет! Вот подборка тем с похожими вопросами и ответами на Ваш вопрос: Как изменить текст в теге div с помощью JS