剛敲了一個形象切換,並且遇到了一個小問題來了:jQuery的查找特定的IMG ATTR(SRC)
我有隱藏的三幅圖像,並懸停在相應的縮略圖時,我想添加類的電流到主圖像(以阻止它被隱藏)。
$("#thumbs img").mouseenter(function(){
//this gets the url of the thumb
var imgSrc = $(this).attr("src");
//this removes the last 7 letters
imgSrc = imgSrc.slice(0,-7);
//this adds .jpg to the end
imgSrc = imgSrc + '.jpg';
//This removes all images class of current
$('#mainImg img').removeClass("current");
//I want this to find the image with the src of imgSrc and add the current class
$('#mainImg').find(img.attr("src",imgSrc)).addClass("current");
最後一行是問題,它不起作用 - 有什麼建議嗎?
幾秒打我笑 – corroded 2011-03-26 17:36:26