How to write inside a DIV box with javascript

前端 未结 5 394
情深已故
情深已故 2020-12-28 13:34

I\'m making a mini-game where a player attacks a npc and in the center is a white box (div) that I call (log), because when the player damages/attacks the npc, I want to be

5条回答
  •  长发绾君心
    2020-12-28 13:55

    If you are using jQuery and you want to add content to the existing contents of the div, you can use .html() within the brackets:

    $("#log").html($('#log').html() + " 
    New content!");
    
    
    Initial Content

提交回复
热议问题