Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   PHP, PERL, MySQL, JavaScript (https://forum.antichat.xyz/forumdisplay.php?f=37)
-   -   html css jquery (https://forum.antichat.xyz/showthread.php?t=182242)

barnaki 26.02.2010 20:02

html css jquery
 
как при помощи 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>



Время: 12:36