<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<title>Document</title>
<!-- 点击按钮,打印等腰三角形到页面 -->
<style>
#d1 {
display: none;
}
</style>
</head>
<body>
<script>
function change(){
div = document.getElementById("d1");
if (div.style.display == "block" ) {
div.style.display = "none";
} else {
div.style.display = "block";
}
}
</script>
<input type="button" οnclick="change()" value="点击">
<script>
document.write("<div id = d1>")
for(var i = 5; i > 0; i--){
for(var m = 0; m < 5 - i; m++){
document.write(" ");
}
for(var j = 5 - i; j <5 - i + i * 2 - 1; j++){
document.write("*");
}
document.write("<br>")
}
document.write("</div>")
</script>
</body>
</html>