Add text before or after an HTML element

前端 未结 6 1991
误落风尘
误落风尘 2020-12-09 02:34

If i have an HTML element like

with some text inside or another elements can I add before or after this div some text data without an html element,
6条回答
  •  囚心锁ツ
    2020-12-09 02:40

    Just for the record:

    div.insertAdjacentHTML( 'beforeBegin', yourText );
    

    where div is your child-DIV.

    Live demo: http://jsfiddle.net/ZkzDk/

提交回复
热议问题