通过本文主要向大家介绍了jQuery,左右切换,焦点图等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
演示图:

代码:
$(document).ready(function() {
greyInitRedux();
ieDropdownsNav();
ieDropdownsFilter();
itemViewer();
jsTabsetInit();
slider();
headerTabs();
carousel();
emergencyClose();
replyLinks();
adjournLinks();
zebra_strip_rows();
visitor_site_slideshow();
});
var carousel_round = 0;
/*-------------------------------------------
Grey Initial Values
-------------------------------------------*/
function greyInitRedux() {
$("input.filled, textarea.filled").focus(function(e){
if(this.value == this.defaultValue)
{
$(this).removeClass('filled');
this.value= '';
}
$(this).blur(function(f){
if(this.value == this.defaultValue) {
$(this).addClass('filled');
} else if(this.value == "") {
this.value = this.defaultValue;
$(this).addClass('filled');
}
});
})
}
/*-------------------------------------------
IE6 CSS Main Nav Dropdowns
-------------------------------------------*/
function ieDropdownsNav() {
if(document.all&&document.getElementById)
{
navRoot = document.getElementById('main-nav');
if (!navRoot) { return false; }
for(i=0; i<navRoot.childNodes.length; i++)
{
node = navRoot.childNodes[i];
if (node.nodeName=='LI')
{
node.onmouseover=function()
{
this.className+=' over';
}
node.onmouseout=function()
{
this.className=this.className.replace(' over', '');
}
}
}
}
}
/*-------------------------------------------
IE6 CSS Main Nav Dropdowns
-------------------------------------------*/
function ieDropdownsFilter() {
if(document.all&&document.getElementById)
{
navRoot = document.getElementById('filter-drop');
if (!navRoot) { return false; }
for(i=0; i<navRoot.childNodes.length; i++)
{
node = navRoot.childNodes[i];
if (node.nodeName=='DIV')
{
node.onmouseover=function()
{
this.className+=' over';
}
node.onmouseout=function()
{
this.className=this.className.replace(' over', '');
}
}
}
}
}
/*-------------------------------------------
View More
-------------------------------------------*/
function itemViewer() {
//$(document).delegate('#filter-drop a, .expandable > .load, .filter-nav a', 'click', function (e)
//$(document).delegate('.expandable > .load, .filter-nav a', 'click', function (e)
$(document).delegate('.filter-nav a', 'click', function (e)
{
// get the src for the content we're trying to view
var dataSrc = $(this).attr('data-src');
// determine whether we're trying to sort the existing view
if($(this).attr('data-sort')) {
var dataSort = $(this).attr('data-sort');
} else {
var dataSort = $('.filter-nav > li > a').attr('data-sort');
}
// how many items do we have?
var itemOffset = $('.expandable .listing > li').size();
//find out if we clicked the menu, if so, clear out everything and add data attribute to the load more
if($(this).closest('div').hasClass("filter"))
{
var hiddenDiv = $('<div />', {
"class": "items hidden spacer",
"height": $('.expandable').outerHeight()
});
$('.expandable > .load').before(hiddenDiv);
$('.expandable > ul, .expandable > div:not(.spacer)').remove();
$('.load').attr('data-src',dataSrc);
// Change Class of Dropdown Toggle
var clickedClass = $(this).parent().attr('class');
$("#filter-drop strong").removeClass().addClass(clickedClass);
// Change Text of Dropdown Toggle
var thisLabel = $(this).text();
$("#filter-drop strong span").text(thisLabel);
// Grab datasrc from clicked-on menu item and populate the filters with it
$('.filter-nav a').attr('data-src' , dataSrc);
$('.filter-nav li').removeClass('active');
$('.filter-nav > li').eq(0).addClass('active');
}
//find out if we clicked the filter nav, if so let's switch the active class
if($(this).closest('ul').hasClass("filter-nav")) {
$('.filter-nav li').removeClass('active');
$(this).parent().addClass('active');
//Also let's remove all the items before replacing them with what we want
var hiddenDiv = $('<div />', {
"class": "items hidden spacer",
"height": $('.expandable').outerHeight()
});
$('.expandable > .load').before(hiddenDiv);
$('.expandable > ul, .expandable > div:not(.spacer)').remove();
}
$.get(dataSrc, { offset: itemOffset, sort: dataSort }, function(data) {
$('.expandable .spacer').remove();
var hiddenDiv = $('<div class="items hidden"></div>');
$('.expandable > .load').before(hiddenDiv);
$(hiddenDiv).append(data).hide().removeClass("hidden").fadeIn();
});
e.preventDefault();
});
}
function jsTabsetInit() {
var $tabset = $('.heading-tabset').eq(0);
var $tablist = $('<ul />', {"class": "heading-tab"});
$tabset.prepend($tablist);
$('div.heading-tab h3').each(function()
{
var $anchor = $('<a />', {
"class": $(this).attr('class'),
"onClick": '_gaq.push([\'_trackEvent\', \'Connect\', \'Click\', \'Head'+$(this).attr('class')+'\', 3]);',
"href": "#",
"html": $(this).html()
});
var $li = $('<li />');
$li.append($anchor);
$tablist.append($li);
});
$('div.heading-tab').remove();
$('.heading-tabset:gt(0)').each(function()
{
$tabset.append($(this).find('.listing'));
$(this).remove();
});
}
function slider() {
$('.slider').each(function()
{
// As we loop through the slider items we'll document the tallest one and the left position
// of each element
var maxHeight = 0, lastWidth = 0;
// grab the slider and make sure the overflow is hidden and it has a defined width
var $slider = $(this);
$slider.css('width', $slider.outerWidth());
$slider.css('position', 'relative');
$slider.css('overflow', 'hidden');
// store the index (or the currently "selected" slide)
$slider.prop('index', 0);
// loop through each of the direct children
$slider.find('> *').each(function()
{
// localize the child as a jQuery object
var $li = $(this);
// if this is the tallest child, document it
if ($li.outerHeight() > maxHeight)
{
maxHeight = $li.outerHeight();
}
// position each child to the immediate right of its preceding sibling
$li.css('position', 'absolute');
$li.css('top', 0);
$li.css('left', lastWidth);
// update our maths so we know where to place the next sibling
lastWidth+= $li.outerWidth();
});
// set the height of the slider based on the tallest child
//$slider.css('height', maxHeight);
// build the previous control button and store a reference to its related slider
var $previous = $('<a />', {"class": "prev disabled", "href": "#", "text": "Previous"});
$previous.prop('slider', $slider);
// build the next control button and store a reference to its related slider
var $next = $('<a />', {"class": "next", "href": "#", "text": "Next"});
$next.prop('slider', $slider);
// build the controls div and add it to the markup
var $controls = $('<div />

