<script src="js/jquery-3.7.1.min.js"></script>
<style type="text/css">
button{
font-size: 2rem;
}
</style>
<body style="font-size: 2.4rem;text-align: center;">
<br>
<p><img id="photo" src="images/lighton.png"></p>
<p>
<button id="open">開燈</button>
<button id="close">關燈</button>
</p>
</body>
<script type="text/javascript">
$(document).ready(function(){
});
</script>
<script>
$(document).ready(function(){
$("#open").on("click", function(){});
$("#close").on("click", function(){});
});
</script>
<script>
$(document).ready(function(){
$("#open").on("click", function(){
alert($("#photo").attr("src"));
});
$("#close").on("click", function(){});
});
</script>
<script>
$(document).ready(function(){
$("#open").on("click", function(){
$("#photo").attr("src","images/lighton.png"); //設定成開燈的圖片檔名
});
$("#close").on("click", function(){
$("#photo").attr("src","images/lightoff.png"); //設定成關燈的圖片檔名
});
});
</script>