I have the current code:
<script type="text/javascript">
$('ul.products-slideshow-thumbs li a').bind("mousedown", function(){
$(this).toggleClass("current");
});
</script>
<ul class="products-slideshow-thumbs">
<li><a href="#"><img src="product-slides/thumbs/1.jpg" /></a></li>
<li><开发者_如何学JAVA;a href="#"><img src="product-slides/thumbs/2.jpg" /></a></li>
<li><a href="#"><img src="product-slides/thumbs/3.jpg" /></a></li>
</ul>
But it's not working properly (basically, nothing happens).
Any suggestions? (I'm afraid I'm fairly new to jQuery/JavaScript.) Thank you!Try this:
<script type="text/javascript">
$(document).ready(function(){
$('ul.products-slideshow-thumbs li a').click(function(){
$(this).toggleClass("current");
});
});
</script>
<ul class="products-slideshow-thumbs">
<li><a href="#"><img src="product-slides/thumbs/1.jpg" /></a></li>
<li><a href="#"><img src="product-slides/thumbs/2.jpg" /></a></li>
<li><a href="#"><img src="product-slides/thumbs/3.jpg" /></a></li>
</ul>
I copied your code and it seemed to work for me. Have you also tried the .click()
jquery method?
http://jsfiddle.net/jordanlewis/X6mn5/
精彩评论