麻烦将行悬停在TD上

时间:2018-09-25 17:35:00

标签: html css html-table hover

当我尝试将行悬停在TD上时遇到一些问题。我找不到解决方案。我在某些论坛上看到我可能需要JS / jQuery ...有人可以给我解决方案吗?我将向您展示我的代码。.我只需要启动一些内容,之后就可以解决....

 server <- function(input, output, session) {

  edits <- callModule(editMod, "editor", mapview()@map)

  observeEvent(input$clear, {
    ### some other things will happen here like uploading dropbox
      edits <- callModule(editMod, "editor", mapview()@map)
  })
}

并且我正在尝试使用悬停效果重现该表:

https://www.templatemonster.com/demo/69211.html打开模板后,从菜单转到“部门”。

1 个答案:

答案 0 :(得分:1)

您可以在javascript函数中使用鼠标悬停来尝试解决此问题。您可以在“ onmouseover”中更改td的颜色(或执行其他任何操作),然后在“ onmouseout”中更改它的颜色。

查看我的代码:

** HTML:**

<tr>
          <td></td>
          <td onmouseover="changeColorRed(this)" onmouseout="normalColor(this)" rowspan="4" style="background-color:rgb(255,104,90)">
            <p class="tt-table-p">Pediatrics</br> <span class="tt-table-r">  Room 15 </br></br> <span class="tt-table-hours"> 17:30 - 19:30 </span></br></br> <span class="tt-table-dr">  Dr. Julia Jameson </span></p>
          </td>
          <td onmouseover="changeColorRed(this)" onmouseout="normalColor(this)" rowspan="4" style="background-color:rgb(0,106,121)">
            <p class="tt-table-p">Pulmonary</br> <span class="tt-table-r">  Room 113 </br></br> <span class="tt-table-hours"> 17:30 - 19:30 </span></br></br> <span class="tt-table-dr">  Dr. Rodney Stratton </span></p>
          </td>
          <td onmouseover="changeColorRed(this)" onmouseout="normalColor(this)" rowspan="4" style="background-color:rgb(222,184,135)">
            <p class="tt-table-p">Ophtalmology</br> <span class="tt-table-r">  Room 25 </br></br> <span class="tt-table-hours"> 12:30 - 15:00 </span></br></br> <span class="tt-table-dr">  Dr. Amy Adams </span></p>
          </td>
          <td onmouseover="changeColorRed(this)" onmouseout="normalColor(this)" rowspan="4" style="background-color:rgb(222,184,135)">
            <p class="tt-table-p">Ophtalmology</br> <span class="tt-table-r">  Room 25 </br></br> <span class="tt-table-hours"> 12:30 - 15:00 </span></br></br> <span class="tt-table-dr">  Dr. Amy Adams </span></p>
          </td>
        </tr>

JavaScript:

function changeColorRed(x) {
    var temp = x.style.backgroundColor;
    localStorage.setItem("color", temp); // store the last backgroundColor
    x.style.backgroundColor = "red";
}

function normalColor(x) {
    var lastColor = localStorage.getItem('color'); // find the last backgroundColor
    x.style.backgroundColor = lastColor;
}