这是我编写并停留的前几行Javascript。
<div id=form_template2 style="border: 1px solid black"></div>
<script>
const form_template = document.getElementById('form_template2')
console.log(form_template.removeAttribute("style"))
</script>
一旦添加.removeAttribute('style')位,我就在console.log中变得未定义:/
Some functions in JavaScript just don't return anything. And in JavaScript world, that nothing is
undefined
. When you define your own function as:And then you try
console.log(lazy())
on it, the result will be the same -undefined
.removeAttribute doesn't return a value, so you'll get undefined. Check out the documentation of the function at https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute