jQuery CSS and Hover

Hello experts -
I attempting to produce a hover effect over a set of table cells where the 'selected' cell has a dark background, the 'non-selected' cells have no background and on hover the non-selected cells show as a lighter highlight.  I've done the following, which doesn't work right:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test3.aspx.vb" Inherits="test3" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        body { font-family:verdana; font-size:12px; }
        .td1 { padding-left:10px; padding-right:10px; }
        .selected { background:#00f; color:#fff; font-weight:bold; }
    </style>
    <script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('.td1').click(function () {
                $('.td1').removeClass('selected');
                $(this).addClass('selected');
            });
            $('.td1:not(.selected)').hover(function () {
                $(this).css({ 'cursor': 'pointer', 'background': '#b0e2ff' });
            },
            function () {
                $(this).css({ 'cursor': 'default', 'background': 'inherit' });
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table cellspacing="0" cellpadding="0" border="1">
            <tr>
                <td class="td1 selected">Fee</td>
                <td class="td1">Fie</td>
                <td class="td1">Fo</td>
                <td class="td1">Fum</td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

Open in new window

When one of the non-selected cells is clicked I want it to switch to the darker blue, with the hover behavior then moving to the new collection of non-selected cells.  There should be no hover effect above the selected cell.

Can someone give me an assist on how to accomplish this?  Thanks.

-- Rick
MinnRickAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StingRaYCommented:
In your stylesheet, insert "!important" to override the background color.

<style type="text/css">
        body { font-family:verdana; font-size:12px; }
        .td1 { padding-left:10px; padding-right:10px; }
        .selected { background:#00f !important; color:#fff; font-weight:bold; }
    </style>

Open in new window

0
MinnRickAuthor Commented:
Thanks StingRaY.  That's closer, but it's still not quite there.  The 'Fee' (first) cell isn't responding correctly on hover (background color or cursor) when one of the other cells is the selected one.  'Fee' does respond when clicked, but I want it to also get the pointer and light blue background when one of the other cells is selected.  Any thoughts on that?  Thanks again..
0
MinnRickAuthor Commented:
Solved.  Here's what ended up working for me:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test3.aspx.vb" Inherits="test3" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <style type="text/css">
        body { font-family:verdana; font-size:12px; }
        td { padding-left:10px; padding-right:10px; }
        .td1:hover { cursor:pointer; background:#b0e2ff; }
        .selected { background:#00f; color:#fff; font-weight:bold; }
    </style>
    <script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('td').click(function () {
                $('td').removeAttr('class').addClass('td1');
                $(this).toggleClass('td1 selected');
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table cellspacing="0" cellpadding="0" border="1">
            <tr>
                <td class="selected">Fee</td>
                <td class="td1">Fie</td>
                <td class="td1">Fo</td>
                <td class="td1">Fum</td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MinnRickAuthor Commented:
Points your way, StingRaY.  Thanks again for the input - you put me onto some new knowledge and that ultimately led to what I used.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.