javascript解释一下以下函数的意思,这个是一个图片动画代码的一部分,请尽量对每个函数解释一下。 5
functionclassNormal(iFocusBtnID,iFocusTxID){variFocusBtns=$(iFocusBtnID).getElementsB...
function classNormal(iFocusBtnID,iFocusTxID){
var iFocusBtns= $(iFocusBtnID).getElementsByTagName('li');
var iFocusTxs = $(iFocusTxID).getElementsByTagName('li');
for(var i=0; i<iFocusBtns.length; i++) {
iFocusBtns[i].className='normal';
iFocusTxs[i].className='normal';
}
function classCurrent(iFocusBtnID,iFocusTxID,n){
var iFocusBtns= $(iFocusBtnID).getElementsByTagName('li');
var iFocusTxs = $(iFocusTxID).getElementsByTagName('li');
iFocusBtns[n].className='current';
iFocusTxs[n].className='current';
}
function iFocusChange() {
if(!$('ifocus')) return false;
$('ifocus').onmouseover = function(){atuokey = true};
$('ifocus').onmouseout = function(){atuokey = false};
var iFocusBtns = $('ifocus_btn').getElementsByTagName('li');
var listLength = iFocusBtns.length;
iFocusBtns[0].onmouseover = function() {
moveElement('ifocus_piclist',0,0,5);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',0);
}
setInterval('autoiFocus()',5000);
var atuokey = false;
function autoiFocus() {
if(!$('ifocus')) return false;
if(atuokey) return false;
var focusBtnList = $('ifocus_btn').getElementsByTagName('li');
var listLength = focusBtnList.length;
for(var i=0; i<listLength; i++) {
if (focusBtnList[i].className == 'current') var currentNum = i;
}
if (currentNum==0&&listLength!=1 ){
moveElement('ifocus_piclist',0,-330,5);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',1);
} 展开
var iFocusBtns= $(iFocusBtnID).getElementsByTagName('li');
var iFocusTxs = $(iFocusTxID).getElementsByTagName('li');
for(var i=0; i<iFocusBtns.length; i++) {
iFocusBtns[i].className='normal';
iFocusTxs[i].className='normal';
}
function classCurrent(iFocusBtnID,iFocusTxID,n){
var iFocusBtns= $(iFocusBtnID).getElementsByTagName('li');
var iFocusTxs = $(iFocusTxID).getElementsByTagName('li');
iFocusBtns[n].className='current';
iFocusTxs[n].className='current';
}
function iFocusChange() {
if(!$('ifocus')) return false;
$('ifocus').onmouseover = function(){atuokey = true};
$('ifocus').onmouseout = function(){atuokey = false};
var iFocusBtns = $('ifocus_btn').getElementsByTagName('li');
var listLength = iFocusBtns.length;
iFocusBtns[0].onmouseover = function() {
moveElement('ifocus_piclist',0,0,5);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',0);
}
setInterval('autoiFocus()',5000);
var atuokey = false;
function autoiFocus() {
if(!$('ifocus')) return false;
if(atuokey) return false;
var focusBtnList = $('ifocus_btn').getElementsByTagName('li');
var listLength = focusBtnList.length;
for(var i=0; i<listLength; i++) {
if (focusBtnList[i].className == 'current') var currentNum = i;
}
if (currentNum==0&&listLength!=1 ){
moveElement('ifocus_piclist',0,-330,5);
classNormal('ifocus_btn','ifocus_tx');
classCurrent('ifocus_btn','ifocus_tx',1);
} 展开
1个回答
展开全部
classNormal 方法是查找id=iFocusBtnID 和id=iFocusTxID下面的所有li,并设置className属性为'normal',看样子是去掉某些动画样式吧!
classCurrent方法是设置 id=iFocusBtnID 和id=iFocusTxID下面的第n个li的className属性为'current' ,如果是选中或者动画的话应该是设置第n个li为当前帧或者选中的样式
iFocusChange 应该是个初始化过程,初始化时设置'ifocus'的onmouseover和onmouseout事件,鼠标进入'ifocus'时动画会停止,离开时动画继续,
iFocusBtns[0].onmouseover ={...}表示鼠标进入'ifocus_btn'的第一个li时动画还原当初始状态
setInterval('autoiFocus()',5000);定时器,每隔5秒执行一次autoiFocus() 方法
autoiFocus() 中调用moveElement 实现了动画效果
classCurrent方法是设置 id=iFocusBtnID 和id=iFocusTxID下面的第n个li的className属性为'current' ,如果是选中或者动画的话应该是设置第n个li为当前帧或者选中的样式
iFocusChange 应该是个初始化过程,初始化时设置'ifocus'的onmouseover和onmouseout事件,鼠标进入'ifocus'时动画会停止,离开时动画继续,
iFocusBtns[0].onmouseover ={...}表示鼠标进入'ifocus_btn'的第一个li时动画还原当初始状态
setInterval('autoiFocus()',5000);定时器,每隔5秒执行一次autoiFocus() 方法
autoiFocus() 中调用moveElement 实现了动画效果
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询