2012-11-30 45 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