将当前类css应用于图像

时间:2012-11-30 10:20:12

标签: html image rotator

我有一种图像轮播,它会自动并在悬停时用大图像标题交换图像大拇指。这是完美的,但现在我已经意识到我想为当前显示的每个拇指添加一些指示。我以为我可以应用div.container img.current并给它一些属性,值..但它没有用。

所以我想我可以要求大家提供一个有效的快速解决方案。

这是我的代码

<div class="container-thumbs">

<div class="big-image-thumbnail">

<a href=".html"onmouseover="document.getElementById('bigImage').src='.jpg'">

<img src=".jpg" /></a><p>Title</p>

</div>

1 个答案:

答案 0 :(得分:1)

使用j-query toggleClass()函数

这是一个例子

<head>

<style>

p { margin: 4px; font-size:16px; font-weight:bolder;

cursor:pointer; }

.blue { color:blue; }

.highlight { background:yellow; }
</style>
 <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>

<body>

  <p class="blue">Click to toggle</p>

  <p class="blue">highlight</p>

  <p class="blue">on these</p>

  <p class="blue">paragraphs</p>

<script>

   $("p").click(function () {

   $(this).toggleClass("highlight");

});

 </script>

</body>