单击按钮时突出显示行 [英] Highlight row when clicked on button

查看:146
本文介绍了单击按钮时突出显示行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击该行的编辑按钮时,我正在使用以下脚本突出显示该行.当我点击按钮时,我正在传递行的ID!我的问题是该代码在Mozila Firefox中有效,但在Google Chrome上却无效.以下代码有什么问题.

I am using following script to highlight row when I clicked edit button of that row. I am passing Id of row when I click on button! My problem is the code is working in Mozila Firefox but not on Google Chrome. What is wrong in following code.

function high(id)
{
    $('tr').removeAttr('style'); 
    document.getElementById(id).style="background-color:#eeeeea;color:#000000;font-weight:500;";
}

推荐答案

尝试一下,

$('#'+id).attr("style","background-color:#eeeeea;color:#000000;font-weight:500;");

在chrome上运行.

原因,可以是样式是其中具有某些属性的对象 chrome可能无法覆盖它.因此,您的自定义字符串 样式传递的内容将不适用于该样式,因此不会对该样式进行任何更改 元素.

The reason, can be style is an object which has some properties in it and chrome may not allow to overwrite it. So the custom string you passed in style will not apply to it, hence no changes applied to the element.

这篇关于单击按钮时突出显示行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆