我嘗試執行添加了展示類的onclick事件,但是,當單擊「創建新目標」時,我無法讓我的new-goal-container
顯示。使用onclick addClass獲取div
我不希望這是一個切換,只是一個添加類。正如我的代碼顯示的,我試圖讓這個在css中快速淡出。有沒有更好的方法來解決這個問題,因爲現在即使沒有顯示div仍然佔用空間,當容器不可見時,我希望它看起來好像不存在。
$("#new-goal-button").click(function() {
$("#new-goal-container").addClass("show");
});
#new-goal-container {
-webkit-opacity: 0;
opacity: 0;
margin-top: 30px;
border: 1px solid black;
height: 500px;
width: 400px;
padding: 10px;
}
.show {
-webkit-opacity: 1;
opacity: 1;
-webkit-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="new-goal-button">Create new goal</div>
<div id="new-goal-container">
<input type="text" placeholder="Goal Title">
<textarea placeholder="Goal Description">
</div>
'textarea'沒有關閉.. – Rayon