开发者

JS in Opera: row.bgColor change causes issues

开发者 https://www.devze.com 2023-01-11 23:03 出处:网络
I\'m using the following Java Script Code: function activeTr( row ) { row.bgColor=\'#F1E1D1\'; document.body.style.cursor = \'pointer\';

I'm using the following Java Script Code:

function activeTr( row ) {
    row.bgColor='#F1E1D1';
    document.body.style.cursor = 'pointer';
}

function inactiveTr( row ) {
    row.bgColor='transparent';开发者_C百科
    document.body.style.cursor = 'default';
}

Respective the following HTML:

<table>
    <tr bgcolor="transparent" class="" onclick="showFoo('1')" onmouseout="inactiveTr(this)" onmouseover="activeTr(this)">
        <td>fooburg</td>
    </tr>
</table>

Everything works fine with activeTr(), but inactiveTr() switches to a light green instead of transparent background. This issue occurs only in Opera's current version (both Windows & Mac). Firefox/Chrome/Safari behave correctly on the same plattforms.

Question: please let me know if you have ideas how to fix this.


Sometimes one has to explain the problem to find a solution. I adjusted the Java Script to the following (requires jQuery) and created a CSS class named hover:

function activeTr( row ) {
    document.body.style.cursor = 'pointer'; 
    $(row).addClass("hover");
}

function inactiveTr( row ) {
    $(row).removeClass("hover");
    document.body.style.cursor = 'default';
}

Everything works as expected now, even in Opera ;-)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号