當用戶點擊按鈕時,使用ng-click指令,我調用函數openAbout(),我想要顯示一個div並隱藏所有其他元素。它與這個代碼一起工作,但是有沒有什麼要做兩個陳述,而不是五個?我想舉個例子,首先被顯示,其他所有人都隱藏起來。由於如何使用JS顯示一個元素並隱藏所有其他元素
<md-button id="about" ng-click="openAbout()">
About Us
</md-button>
$scope.openAbout=function() {
document.getElementById("first").style.display = "block";
document.getElementById("second").style.display = "none";
document.getElementById("third").style.display = "none";
document.getElementById("fourth").style.display = "none";
document.getElementById("fifth").style.display = "none";
};
是的,我有角 – frontendgirl