2012-11-30 46 views
0

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

所以我想我可以问你所有的一个有效的快速解决方案。

这里是我的代码

<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

使用J-查询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> 
+0

谢谢你的提示!我会去看看它! –

+0

它不工作。 –

+0

它确实为单击事件工作..让我看看..我会让你知道 – user1643087