我在nettuts.com上使用了一个稍微修改过的Tabbed jQuery幻灯片版本。我基本上试图让一个定位的div与图像一起显示在页面加载时。目前它仅在显示下一个标签时出现。
我的js代码在
之下$mainbanner = {
context: false,
tabs: false,
timeout: 7000, // time before next slide appears (in ms)
slideSpeed: 1000, // time it takes to slide in each slide (in ms)
tabSpeed: 300, // time it takes to slide in each slide (in ms) when clicking through tabs
fx: 'scrollLeft', // the slide effect to use
init: function() {
// set the context to help speed up selectors/improve performance
this.context = $('#mainbanner');
// set tabs to current hard coded navigation items
this.tabs = $('ul.tabbed-nav li', this.context);
// remove hard coded navigation items from DOM
// because they aren't hooked up to jQuery cycle
this.tabs.remove();
// prepare mainbanner and jQuery cycle tabs
this.preparemainbanner();
},
preparemainbanner: function() {
// initialise the jquery cycle plugin -
// for information on the options set below go to:
// http://malsup.com/jquery/cycle/options.html
$('div.tabbedcontent > ul', $mainbanner.context).cycle({
fx: $mainbanner.fx,
timeout: $mainbanner.timeout,
speed: $mainbanner.slideSpeed,
fastOnEvent: $mainbanner.tabSpeed,
pager: $('ul.tabbed-nav', $mainbanner.context),
pagerAnchorBuilder: $mainbanner.prepareTabs,
before: $mainbanner.activateTab,
pauseOnPagerHover: true,
pause: true
});
},
prepareTabs: function(i, slide) {
// return markup from hardcoded tabs for use as jQuery cycle tabs
// (attaches necessary jQuery cycle events to tabs)
return $mainbanner.tabs.eq(i);
},
activateTab: function(currentSlide, nextSlide) {
// get the active tab
var activeTab = $('a[href="#' + nextSlide.id + '"]', $mainbanner.context);
// inserts .tab-arrow on activeTab
activeTab.parent().append('<div class="tab-arrow"></div>');
// if there is an active tab
if(activeTab.length) {
// remove active styling from all other tabs
$mainbanner.tabs.removeClass('on'/*,'tab-arrow'*/);
// add active styling to active button
activeTab.parent().addClass('on');
}
}
};
这是插入div的代码:
activeTab.parent().append('<div class="tab-arrow"></div>');
答案 0 :(得分:0)
加
$('ul.tabbed-nav li:first').append('<div class="tab-arrow"></div>');
准备好了