Add text to the newly created div using JavaScript

Add text to the newly created div using JavaScript

Codify Academy

8 лет назад

5,331 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@Sulimankhayyat
@Sulimankhayyat - 19.09.2021 16:20

Why would I add text with JS if could do it with HTML ?! I'm looking to add a caret on click so client can add their text on the window

Ответить
@harehnkaundun1406
@harehnkaundun1406 - 23.07.2018 23:08

That was concise and helpful. keep it up

Ответить
@abdulrahmanrateb1510
@abdulrahmanrateb1510 - 04.03.2017 17:52

HI
i have Q about javascript! specifically the appending part!

when i type the code:

<button id="textappender">click here!</button>

<div id="add">everything is...<div>
.........................................................

document.getElementById("textappender").onclick=function(){

document.getElementById("add").innerHTML=

document.getElementById("add").innerHTML + "awesome!";
}

i got the word "awesome"over and over

like:

(everything is..."awesome!"awesome!"awesome!"awesome!"awesome!"awesome!"awesome!.)
how can i make it shows only once!
can you help please ^^?

Ответить