Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

jquery tablesorter rows with hover css

Posted on 2010-09-01
16
Medium Priority
?
2,953 Views
Last Modified: 2012-05-10
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
Comment
Question by:karelog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 4
  • 3
16 Comments
 
LVL 8

Expert Comment

by:MelMc
ID: 33579346
Can you send the source or possibly use something like firebug to see exactly where the hover is geting applied?
0
 

Author Comment

by:karelog
ID: 33580107
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
 

Author Comment

by:karelog
ID: 33580123
Sorry the double post,

here is the main javascript and the css
jsCargos-Rubros.js
style.css
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:karelog
ID: 33580137
Sorry the triple post >.<

could you guide me on how to follow the css using firebug?
0
 

Author Comment

by:karelog
ID: 33580211
here is a picture of firebug and the css that recognize with hover
2010-09-01-14.02.00.png
0
 
LVL 8

Expert Comment

by:MelMc
ID: 33580262
try adding td after odd in the class
0
 

Author Comment

by:karelog
ID: 33580440
could you be more specific please?
0
 
LVL 8

Expert Comment

by:MelMc
ID: 33580496
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
 

Author Comment

by:karelog
ID: 33580666

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
 
LVL 8

Expert Comment

by:MelMc
ID: 33580886
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
 

Author Comment

by:karelog
ID: 33580998
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
 
LVL 16

Expert Comment

by:Steve Krile
ID: 33597115
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
 

Author Comment

by:karelog
ID: 33597920
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
 
LVL 16

Accepted Solution

by:
Steve Krile earned 2000 total points
ID: 33598059
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
 

Author Closing Comment

by:karelog
ID: 33599144
=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
 
LVL 16

Expert Comment

by:Steve Krile
ID: 33599190
It's hard to tell who is happier in these situations....the asker or the answerer.  Glad I could help.
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question