Показать сообщение отдельно
  #5 (permalink)  
Старый 11.02.2013, 00:20
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,108

Deff,
немного сократил ваш код.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Подсветка колонок таблиц с jQuery</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>


<script type="text/javascript">

$(document).ready(function () {

    $('#tableone td').mouseenter(function () { //alert("A")
        var tr = $(this).parent('tr');
        var Col = tr.find('td').index(this);
        var Span = $('#tableone tr').index(tr.get(0));
        tr.find('td:lt(' + Col + ')').addClass('hover');
        $('#tableone tr:lt(' + Span + ')').find('td:eq(' + Col + ')').addClass('hover');

    }).mouseleave(function () {
        $('#tableone td').removeClass('hover');
    });
});

</script>

</head>

<body>
<style type="text/css">
	body {
		background-color:#f0f0f0;
	}

	table {
		width:600px;
		margin:0 auto;
		font-family:Arial, Helvetica, sans-serif;
		border-spacing:0px;
	}

	td:hover, td.betterhover, td.hover {
		background-color:#c0e2ff;
		box-shadow:0 0 1px #006fcd;
	}

</style>

<table id="tableone">
		<tbody>
			<tr><td>X</td><td>-</td><td>X</td><td>X</td><td>-</td><td>-</td><td>-</td><td>-</td></tr>
			<tr><td>X</td><td>-</td><td>X</td><td>X</td><td>-</td><td>-</td><td>-</td><td>-</td></tr>

			<tr><td>X</td><td>-</td><td>X</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td></tr>
			<tr><td>-</td><td>-</td><td>X</td><td>-</td><td>X</td><td>X</td><td>-</td><td>X</td></tr>

			<tr><td>X</td><td>-</td><td>X</td><td>X</td><td>-</td><td>-</td><td>-</td><td>X</td></tr>
			<tr><td>X</td><td>-</td><td>X</td><td>X</td><td>-</td><td>-</td><td>-</td><td>X</td></tr>

			<tr><td>X</td><td>X</td><td>-</td><td>X</td><td>-</td><td>X</td><td>-</td><td>X</td></tr>
			<tr><td>X</td><td>X</td><td>-</td><td>X</td><td>-</td><td>-</td><td>-</td><td>-</td></tr>

			<tr><td>X</td><td>X</td><td>-</td><td>X</td><td>-</td><td>-</td><td>X</td><td>-</td></tr>
			<tr><td>X</td><td>-</td><td>X</td><td>-</td><td>X</td><td>-</td><td>-</td><td>-</td></tr>

			<tr><td>X</td><td>-</td><td>X</td><td>X</td><td>-</td><td>-</td><td>-</td><td>-</td></tr>
			<tr><td>X</td><td>X</td><td>X</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td></tr>

		</tbody>
	</table>

</body>
</html>
Ответить с цитированием