我有details標記css高度我想通過javascript/jquery進行調整。如果details標籤具有open屬性,那麼height將是200,否則它將是40,但我無法做到這一點。HTML根據打開/關閉屬性詳細標記高度調整
$jq("#ProjectQuestionAnswerBottomPanel").click(function(){
console.log("change occur");
if($jq("#ProjectQuestionAnswerBottomPanel").attr("open")){
console.log("open found");
$jq("#ProjectQuestionAnswerBottomPanel").css("height","");
$jq("#ProjectQuestionAnswerBottomPanel").css("height","200px");
}else{
console.log("open found");
$jq("#ProjectQuestionAnswerBottomPanel").css("height","");
$jq("#ProjectQuestionAnswerBottomPanel").css("height","40px");
}
});
,而我的細節HTML是
<details class="bottom-panel" id="ProjectQuestionAnswerBottomPanel" style="position: fixed;
bottom: 80px;
right: 0px;
background: rgb(244, 238, 238);
padding-left:5px;
color: rgb(180, 17, 17);
overflow: scroll;
height: 40px;
">
<div id="ProjectQuestionAnswer">
</div>
</details>
檢查了這一點https://jsfiddle.net/5evfa9k1/ – razorranjan