我是jquery的新手,正在尝试执行一个基本示例。实际上,我正在使用Visual代码进行编程。这是我的代码:
<head>
<script type="text/javascript">
function myFunction() {
var checkBox = document.getElementById("myCheck");
var text = document.getElementById("text");
if (checkBox.checked == true) {
text.style.display = "block";
} else {
text.style.display = "none";
}
}
</script>
</head>
<body>
<p>Display some text when the checkbox is checked:</p>
Checkbox: <input type="checkbox" id="myCheck" onclick="myFunction()">
<p id="text" style="display:none">Checkbox is CHECKED!</p>
</body>
angular.jason文件:
"styles": [
"src/styles.scss",
"./node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": [
"./node_modules/jquery/dist/jquery.min.js",
"./node_modules/popper.js/dist/umd/popper.min.js",
"./node_modules/bootstrap/dist/js/bootstrap.min.js",
"./node_modules/bootstrap/dist/js/bootstrap.min.js",
"./node_modules/simpl-theme-bootstrap/dist/js/simpl-theme-bootstrap.bundle.js"
]
错误:
未捕获的ReferenceError:在HTMLInputElement.onclick((index :: 1)
中未定义myFunction
我已将功能移至主体底部,但未解决问题。有任何想法/提示吗?