<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <button type="button" style="color: salmon" οnclick=show1()>哥哥</button> <button type="button" οnclick=show2()>弟弟</button> <div style="display: block" id="teachers"> I am a students </div> <div style="display: none" id="students"> I will be better </div> </body> <script type="text/javascript"> function show1(){ document.getElementById("teachers").style.display="block"; document.getElementById("students").style.display="none"; } function show2(){ document.getElementById("teachers").style.display="none"; document.getElementById("students").style.display="block"; } </script> </html>
通过js实现选择按钮出现不同内容
最新推荐文章于 2024-04-15 08:33:14 发布