列表

详情


FED50. 根据ID获取元素

描述

请补全JavaScript函数,根据id获取html模块中ul标签下第二个li元素并返回。

原站题解

HTML/CSS/JavaScript 解法, 执行用时: 353ms, 内存消耗: 78972KB, 提交时间: 2021-11-20

{"css":"","js":"function getLI(id){\n    // 补全代码\n    return document.querySelector(`#${id}`);\n}","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1691ms, 内存消耗: 77812KB, 提交时间: 2022-02-08

{"css":"","js":"function getLI(id){\n    // 补全代码\n    return document.getElementsByTagName('li')[1]\n}","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1736ms, 内存消耗: 77772KB, 提交时间: 2021-12-13

{"css":"","js":"function getLI(id){\n    // 补全代码\n    let bb = document.getElementById(id);\n    \n}","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1736ms, 内存消耗: 77772KB, 提交时间: 2021-12-02

{"css":"","js":"function getLI(id){\n    // 补全代码\n    \n    return li = document.querySelectorAll(\"#\"+id+\">li\")[1]\n}","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1736ms, 内存消耗: 77812KB, 提交时间: 2021-12-17

{"css":"","js":"function getLI(id){\n    // 补全代码\n    var oUl = document.getElementById(id);\n    return oUl\n}","html":"","libs":[]}

上一题