Показать сообщение отдельно
  #4 (permalink)  
Старый 10.02.2013, 22:58
без статуса
Отправить личное сообщение для Deff Посмотреть профиль Найти все сообщения от Deff
 
Регистрация: 25.05.2012
Сообщений: 8,219

<!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 () {

    $('body').on('mouseenter','#tableone td',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');

    }).on('mouseleave','#tableone td',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>

Последний раз редактировалось Deff, 11.02.2013 в 06:38.
Ответить с цитированием