Selective CSS

Hi,

I have some html which has two different tables.

wrt one of the tables, I want to change the color of a row on hover and change it again on select.
With the other table I want nothing to happen on hover or select.

I am able to get the hover and select to work, however, I am not sure how to restrict it to just one table.  See attached code snippet.  I have tried adding a class selector, but obviously havn't gotten it right.

Thanks for all help
Phil

<style type="text/css">	
	tr:hover .row  {
		cursor: pointer;
		background-color: whitesmoke;
	}
	.select .row {
		background-color: rgb(208,208,208);
	}
</style>


<table border='0'  width=100%>
	<tr class='row' align='center'  onclick='messSelect("row-1");' id='row-1' >
		<td >
			blah blah
		</td>
	</tr>
	<tr class='row' align='center'  onclick='messSelect("row-2");' id='row-2' >
		<td >
			blah blah
		</td>
	</tr>
</table>


<table border='0'  width=100%>
	<tr   >
		<td >
			xyxyxyxy
		</td>
	</tr>
	<tr   >
		<td >
			xyxyxyxy
		</td>
	</tr>
</table>

Open in new window

BeerFizzAsked:
Who is Participating?
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.

LZ1Commented:
In order to target one table and not the other, you would need to add id="table1" to one of the tables.
 
0
LZ1Commented:
Sorry about the short post above.  
After you add the ID to the table, you will also need to add it to the CSS.  This will help you target it more effectively.
 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<style type="text/css">  
    #table1 tr:hover .row  { 
                cursor: pointer; 
                background-color: whitesmoke; 
        } 
        .select .row { 
                background-color: rgb(208,208,208); 
        } 
</style> 
 
 

</style> 
</head> 
<body> 
    <table border='0'  width="100%" id="table1"> 
        <tr class='row' align='center'  onclick='messSelect("row-1");' id='row-1' > 
                <td > 
                        blah blah 
                </td> 
        </tr> 
        <tr class='row' align='center'  onclick='messSelect("row-2");' id='row-2' > 
                <td > 
                        blah blah 
                </td> 
        </tr> 
</table> 
 
 
<table border='0'  width="100%"  id="table2"> 
        <tr   > 
                <td > 
                        xyxyxyxy 
                </td> 
        </tr> 
        <tr   > 
                <td > 
                        xyxyxyxy 
                </td> 
        </tr> 
</table>
</body>

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
BeerFizzAuthor Commented:
Works great :)
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
CSS

From novice to tech pro — start learning today.