• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3072
  • Last Modified:

jquery tablesorter rows with hover css

Hello!

I am using jQuery 1.4.2 + jQuery UI 1.8.2 ( jQueryUI )

I am complementing that with jquery.tablesorter 2.0.3 + filter + paging ( jquery.tablesorter )


So, here is the deal.
In jquery.tablesorter CSS file I have the next code:
 
table.tablesorter tbody tr :hover
{
    background-color:#FBD34A;
}

Open in new window

This means that when my mouse goes over a <tr> inside the <tbody> it will display that color.

Although for some reason the entire row doesn't highlight. it only highlight the cell below the cursor.



¿anyone knows why this happens?
I am trying to avoid using jQuery onMouseOver and onMouseOut cause it will not be optimum.


in advance, many thanks!

PS: When I use this code instead the above one:
table.tablesorter tbody tr:hover
{
    background-color:#FBD34A;
}

Open in new window

it doesn't show anything on mouseover D: (note that I only deleted the space between the "tr" and the ":hover"
0
karelog
Asked:
karelog
  • 9
  • 4
  • 3
1 Solution
 
MelMcCommented:
Can you send the source or possibly use something like firebug to see exactly where the hover is geting applied?
0
 
karelogAuthor Commented:
here's the source, though I don't think you'll have the time to follow it. There are a several lines of code.


Parametros.aspx
0
 
karelogAuthor Commented:
Sorry the double post,

here is the main javascript and the css
jsCargos-Rubros.js
style.css
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
karelogAuthor Commented:
Sorry the triple post >.<

could you guide me on how to follow the css using firebug?
0
 
karelogAuthor Commented:
here is a picture of firebug and the css that recognize with hover
2010-09-01-14.02.00.png
0
 
MelMcCommented:
try adding td after odd in the class
0
 
karelogAuthor Commented:
could you be more specific please?
0
 
MelMcCommented:
change the name of the class table.tablesorter tbody tr :hover, table tablesorter tbody tr.odd :hover

Add this line to it
 table tablesorter tbody tr.odd td :hover
0
 
karelogAuthor Commented:

I tried several options using your advice, nevertheless I can't make it work.
I tried:
  • table tablesorter tbody tr.odd td :hover     nothing highlighted
  • table.tablesorter tbody tr.odd td :hover     nothing highlighted
  • table.tablesorter tbody tr :hover,
    table.tablesorter tbody tr.odd td :hover     highlighted only even CELLS
So it did not worked D:

0
 
MelMcCommented:
Did you add the line i mentioned to the class or change the entire class name to only the line.

Ultimately the class name I wanted to try is this

table.tablesorter tbody tr :hover, table tablesorter tbody tr.odd :hover, table tablesorter tbody tr.odd td :hover
0
 
karelogAuthor Commented:
I actually replaced it :P

I tried again with your last code. Still the same problem.

Just to be clear, the problem is that the css is highlighting only the cell under the pointer of the mouse.
I need to make that the highlight extends to entire row, not only the cell.

I don't see how adding td (cell) to the class with help, cause I need the tr (row) to be highlighted

T_T
0
 
Steve KrileCommented:
This should do the trick.  There are implied relationships in css script unless you explicitly use the ">" character.  I tried this in FF and IE and both worked.
<!DOCTYPE html>
<html>
	<head>
		<style>
			body{background:#fff;font-family:Arial, Helvetica, sans-serif; font-size:11px;margin: 10px auto;overflow:hidden;}
			table.tablesorter > tbody > tr:hover
			{
				background-color:#FBD34A;
			}

		</style>

		<script src="http://code.jquery.com/jquery-latest.min.js"></script>


	</head>
	<body>
		<table class="tablesorter">
			<tbody>
				<tr>
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
				<tr>
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
				<tr>
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
				<tr>
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
			</tbody>
		</table>


	</body>

</html>

Open in new window

0
 
karelogAuthor Commented:
what the ">" character does exactly?

for some reason I think jQuery is interfiering in the styling.
each row has an "odd" or "even" class attached as you can see in the picture I attached in the earlier post, but in the css file is no "even" class defined T_T

I think I'm gonna die! T_T
0
 
Steve KrileCommented:
That character is a [parent] > [child] designator.

I think I've found your issue.  In the style, you have these two rules:

                  table.tablesorter tbody td {
                        color: #3D3D3D;
                        padding: 4px;
                        background-color: #FFF;
                        vertical-align: top;
                  }
                  table.tablesorter tbody tr.odd td {
                        background-color:#F0F0F6;
                  }

Notice that this applies background color to the TD tag.  So, the hover IS working, but you can't see it because the cell formatting is "on top" of the row.

So, the fix is attached.


<!DOCTYPE html>
<html>
	<head>
		<style>
			body{background:#fff;font-family:Arial, Helvetica, sans-serif; font-size:11px;margin: 10px auto;overflow:hidden;}
		/* tables */
		table.tablesorter {
			font-family:arial;
			background-color: #CDCDCD;
			margin:10px 0pt 15px;
			font-size: 8pt;
			width: 100%;
			text-align: left;
		}
		table.tablesorter thead tr th, table.tablesorter tfoot tr th {
			background-color: #e6EEEE;
			border: 1px solid #FFF;
			font-size: 8pt;
			padding: 4px;
		}
		table.tablesorter thead tr .header {
			background-image: url(bg.gif);
			background-repeat: no-repeat;
			background-position: center right;
			cursor: pointer;
		}
		table.tablesorter tbody td {
			color: #3D3D3D;
			padding: 4px;
			/*background-color: #FFF;*/
			vertical-align: top;
		}


		table.tablesorter tbody tr.even {
			background:#F0F0F6;
		}

		table.tablesorter tbody tr.odd {
			background:#FFFFFF;
		}

		table.tablesorter tbody tr:hover
		{
			background-color:#FBD34A;
		}


		table.tablesorter thead tr .headerSortUp {
			background-image: url(asc.gif);
		}
		table.tablesorter thead tr .headerSortDown {
			background-image: url(desc.gif);
		}
		table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp {
			background-color: #8dbdd8;
		}



		</style>

		<script src="http://code.jquery.com/jquery-latest.min.js"></script>


	</head>
	<body>
		<table class="tablesorter">
			<tbody>
				<tr class="odd">
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
				<tr class="even">
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
				<tr class="odd">
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
				<tr class="even">
					<td>Cell 1</td>
					<td>Cell 1</td>
					<td>Cell 1</td>
				</tr>
			</tbody>
		</table>


	</body>

</html>

Open in new window

0
 
karelogAuthor Commented:
=O

many many many thanks!!!!
you was so right!!
there IS a problem with that TD!!

I applied your css and all worked perfect!!!

Thanks!!! (I'll try to post the solution to the owner of the code in tablesorter.com, I'll reference you!)
0
 
Steve KrileCommented:
It's hard to tell who is happier in these situations....the asker or the answerer.  Glad I could help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 9
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now