JavaScript Adding an ID attribute to another created Element

后端 未结 2 1638
Happy的楠姐
Happy的楠姐 2020-12-08 00:02

I have some code here that will do the following. The code creates an element \"p\" then I append it to a \"div\" in the HTML. I would like that \"p\" I just created have an

2条回答
  •  渐次进展
    2020-12-08 00:37

    You set an element's id by setting its corresponding property:

    myPara.id = ID;
    

提交回复
热议问题