Highlight row is not getting disappear after I click the next table row

风流意气都作罢 提交于 2019-12-02 07:11:42

问题


I need to create background as yellow while selecting the gear icon for the menu option in the table row, I have tried the below code for highlighting the table row,

var view = Core.view.Menu.create({
    model: model,
    menuContext: { ibmm: ibmm },
    anchor: this.$(),
    highlight: this.$().parents('tr:first').css('background-color','yellow')
});
view.show();

While selecting the menu from the table row (hidden) with the gear icon, the background color is coming well.

[![enter image description here][1]][1]

corresponding html file is below

<tr id="ember23242" class="ember-view content-row body-row-view container-view" tabindex="0" aria-label="">

But when I move to the next table row(non hidden), the past table row color is still in yellow color, not getting disappear.

[![enter image description here][2]][2]

I'm using the below css code for creating the highlight when i'm clicking the row

table.content-table.highlighted tr.content-row:focus {
  background: #FFFF99 none 0 0 repeat;
}

Can anybody suggest me code for this. I’m using Ember 1.4.0.


回答1:


you can try below jquery to reset your background color where event will occur on focusout.

$(function(){
  $("table.content-table.highlighted tr.content-row").on("focusout", function(){
        $(this).css('background','#FFFF00 none 0 0 repeat'); // change color code as per your need
  });
});



回答2:


Check the difference between :first and :first-child

var view = Core.view.Menu.create({
    model: model,
    menuContext: { ibmm: ibmm },
    anchor: this.$(),
    highlight: this.$().parents('tr:first-child').css('background-color','yellow')
});
view.show();


来源:https://stackoverflow.com/questions/52184949/highlight-row-is-not-getting-disappear-after-i-click-the-next-table-row

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!