PDA

Просмотр полной версии : html css jquery


barnaki
26.02.2010, 20:02
как при помощи jquery поменять цвета текста ссылок только в одной таблице
<script type="text/javascript" src="javascript/jquery-1.2.1.js"></script>
<script type="text/javascript" src="javascript/functtions.js"></script>
<link rel="stylesheet" type="text/css" href="css/styles.css"></link>
<title>Untitled Document</title>
</head>

<body>

<div class="TableOne">
<table onmouseover="swap();" onmouseout="swap();">
<tr>
<th><a href="#" onMouseOver="swap();" onMouseOut="swap();">гостевая</a></th>
<th><a href="#">гостевая</a></th>
<th><a href="#">гостевая</a></th>
<th><a href="#">гостевая</a></th>

</tr>

</table>
</div>

функция swap

function swap() {
$('tr > th').toggleClass('striped');
}

меняет background-color но color не работает
.striped {
background-color:#FFFFFF;
color:#00cc33;


}
при том что на вссе остальне сслыки это распосторянться не должно

diGriz
26.02.2010, 21:12
Добавь a:visited и a:link. Зачем при эвентах делать отдельную функцию, если можно все сделать в jQuery.

<script src="http://code.jquery.com/jquery-latest.js"></script>
<style type="text/css">
.striped a:visited, a:link{
background-color:#ffffff;
color:#00cc33;
}
</style>
<script>
$(document).ready(function(){
$("th").mouseover(function(){
$(this).toggleClass('striped');
}).mouseout(function(){
$(this).toggleClass('striped');
});
});
</script>
<title>Untitled Document</title>
</head>

<body>

<div class="TableOne">
<table>
<tr>
<th><a href="#">гостевая</a></th>
<th><a href="#">гостевая</a></th>
<th><a href="#">гостевая</a></th>
<th><a href="#">гостевая</a></th>

</tr>

</table>
</div>