Hi,

I've two simple functions for changing a div's content with image
thumbnails. When hovered a thumbnail holder div's content changes. The
code works fine. But I don't feel this functions are well written...
Could you please have a look at them? Is there a better way (design,
code...) to do what I'm triying?

jQuery.fn.selectMain = function() {
                jQuery("#mains div").hide();
                jQuery("#main1").show();
                jQuery("#thumbnails li").eq(0).addClass("active");

                return jQuery("#thumbnails li").hover(function(){
                        jQuery("#mains div").hide();
                        jQuery("#thumbnails li").removeClass("active");
                        var main = $(this).find("a").attr("rel");
                        $(this).addClass("active");
                        jQuery("#" + main).show();

                }, function() { }
                );

};

jQuery.fn.selectVideo = function() {
                jQuery("#vid_thumbnails li").eq(0).addClass("active");

                return jQuery("#vid_thumbnails li").hover(function(){
                        jQuery("#video_news .main_image").empty();
                        var new_vid = $(this).html();
                        var new_title = $(this).find("img").attr("alt");
                        var new_content = new_vid + "<h2>" + new_title + 
"</h2>";
                        jQuery("#video_news .main_image").append(new_content);


                }, function() { }
                );

};

Reply via email to