HTML按钮点击加载JS文件代码示例
<!DOCTYPE html>
<html>
<head>
<script src='https://code.jquery.com/jquery-3.6.0.min.js'></script>
</head>
<body>
<button onclick='loadScript()'>点击加载JS文件</button>
<script>
function loadScript() {
var script = document.createElement('script');
script.src = 'your-script.js';
document.head.appendChild(script);
}
</script>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/pai8 著作权归作者所有。请勿转载和采集!