题解 | #JS动态创建节点#

JS动态创建节点

https://www.nowcoder.com/practice/144422bbf3044e8c8429a88588857c8b

{"html":"<!DOCTYPE html>\n<html>\n\n<head>\n    <meta charset=\"UTF-8\">\n    <style>\n       /* 填写样式 */\n    </style>\n</head>\n\n<body>\n <ul></ul> \n    <script type=\"text/javascript\">\n        let textContent=''\n        let content_left = '<li>'\n        let content_mid = ''\n        let content_right = '</li>' \n       function createLi(array){\n\n        // 补全代码\n        for(var i=0;i<array.length;i++){\n            content_mid = array[i]\n            textContent += content_left+content_mid+content_right \n            ul_content = document.getElementsByTagName('ul')[0]\n            ul_content.innerHTML = textContent\n        }\n        \n\n    \n}       \n    </script>\n</body>\n\n</html>","css":"","js":""}

美美通过

全部评论

相关推荐

点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务