這裏我創建了4個按鈕。點擊後,它應該改變顏色。我想要的是,當我點擊第二個按鈕時,我想要第一個按鈕以及第二個按鈕被着色。我該怎麼做?點擊第二個按鈕,我想要第一個以及第二個按鈕變得有顏色
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<style>
.button {
background-color: white;
border: 1px solid black;
color: white;
padding: 8px 30px;
text-align: center;
text-decoration: none;
display: inline-block;
cursor: pointer;
float:left;
}
</style>
</head>
<body>
<input type="button" class="button" onclick="this.style.backgroundColor = 'red';" value="1">
<input type="button" class="button" onclick="this.style.backgroundColor = 'yellow';" value="2">
<input type="button" class="button" onclick="this.style.backgroundColor = 'green';" value="3">
<input type="button" class="button" onclick="this.style.backgroundColor = 'orange';" value="4">
</body>
</html>
哪裏是你的JavaScript?這和php有什麼關係? – FKEinternet
刪除php標籤,php將無法幫助,因爲它是服務器端。 –
@NoahCristino我相信你的意思是客戶端(在用戶的瀏覽器中) - 或者等待 - 你的意思是* PHP *是服務器端? – FKEinternet