How can I create and style a div using JavaScript?

后端 未结 9 2287
野的像风
野的像风 2020-11-27 10:27

How can I use JavaScript to create and style (and append to the page) a div, with content? I know it\'s possible, but how?

9条回答
  •  春和景丽
    2020-11-27 10:57

    This will be inside a function or script tag with custom CSS with classname as Custom

     var board = document.createElement('div');
     board.className = "Custom";
     board.innerHTML = "your data";
     console.log(count);
     document.getElementById('notification').appendChild(board);
    

提交回复
热议问题