开发者

Using hover to swap images, I don't want to swap images if I'm on '.this_page'

When I land on the page, another function (not shown, that works fine) sets the class of the appropriate nav to '.this_page' and then I roll over, and the images swap correctly, but when I hover and leave 'img.this_page' it swaps, the second time I do the开发者_开发知识库 hover. I don't want it 'img.this_page' to swap. I tried unbinding mouseout, but on hover apparently it rebinds... so each time you hover, it resets.

Page is at http://flourgarden.com/wp/

Here's my function:

function hoverNavs() {
            var baseURL='http://www.flourgarden.com/wp/wp-content/themes/flourgarden/images/nav';
            var cache=[];

            $j('.lcolumn a img').each(function() {

                var t = $j(this);
                var src1 = t.attr('src'); // initial src
                var newSrc = src1.substring(src1.lastIndexOf('/'), src1.lastIndexOf('.')); // let's get file name without extension

                i = baseURL+newSrc+'_select.png';
                cache.push(i);

                t.hover(function(){
                    $j(this).attr('src', baseURL+newSrc+ '_select.' + /[^.]+$/.exec(src1)); //last part is for extension       
                }, function(){
                    if($j(this).class == "this_page") {
                        $j(this).attr('src', baseURL+newSrc+ '_select.' + /[^.]+$/.exec(src1));
                    } else {
                        $j(this).attr('src', baseURL+newSrc+ '.' + /[^.]+$/.exec(src1));
                    }
                });
            });
        }


Is the not filter function what you need to exclude '.this_page'?

$j('.lcolumn a img').not('.this_page')....
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜