[英]Unable to change css using javascript
在handsontable的_afterOnCellMouseOver函數中,當我將鼠標懸停在它們的上方時,我試圖更改其CSS顏色屬性。
_afterOnCellMouseOver(e, coords, td) { if (coords.row === -1 &&& this.hot) { let contElem = document.getElementById(`cont${varId}`); contElem.style.color = "purple"; } }
div.hotColHeaderContainer { display: flex; flex-direction: column; justify-content: center; overflow: visible; position: relative; }
<div class="${styles.hotColHeaderContainer}" id=cont${varId}> </div>
我的div.hotColHeaderContainer包含在一個scss文件中,而我的div包含在一個用於生成列標題的函數中。 varId是根據列標題中使用的變量名稱更改名稱的變量。 有什么原因使我無法從_afterOnCellMouseOver內部更改樣式? 我對javascript,handsontable和CSS非常陌生。
您可以只使用css hover
選擇器。 以下代碼段:
div.hotColHeaderContainer { display: flex; flex-direction: column; justify-content: center; overflow: visible; position: relative; } div.hotColHeaderContainer:hover { color: purple }
<div class='hotColHeaderContainer'>Hello</div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.