这段jS是图片轮换的其中一段代码,有两个地方:1,with关键字有什么用?
2,filters[0].Apply(); 中的filters是js自带的函数吗?因为前面没有声明,他主要有什么用处?它的Apply和play方法有什么用????
代码如下:
function setImg(v){
try{
with (bimg){
filters[0].Apply();
for(var i=0;i<count;i++){
img[i].style.display = 'none';
text[i].style.display = 'none';
}
img[v].style.display = 'block';
text[v].style.display = 'block';
filters[0].play();
}
}
catch(e){
for(var i=0;i<count;i++){
img[i].style.display = 'none';
text[i].style.display = 'none';
}
img[v].style.display = 'block';
text[v].style.display = 'block';
}
}
2,filters[0].Apply(); 中的filters是js自带的函数吗?因为前面没有声明,他主要有什么用处?它的Apply和play方法有什么用????
代码如下:
function setImg(v){
try{
with (bimg){
filters[0].Apply();
for(var i=0;i<count;i++){
img[i].style.display = 'none';
text[i].style.display = 'none';
}
img[v].style.display = 'block';
text[v].style.display = 'block';
filters[0].play();
}
}
catch(e){
for(var i=0;i<count;i++){
img[i].style.display = 'none';
text[i].style.display = 'none';
}
img[v].style.display = 'block';
text[v].style.display = 'block';
}
}
2、css属性,特效。应用和播放。
with 语句通常用来缩短特定情形下必须写的代码量。在下面的例子中,请注意 Math 的重复使用:
x = Math.cos(3 * Math.PI) + Math.sin(Math.LN10)
y = Math.tan(14 * Math.E)
当使用 with 语句时,代码变得更短且更易读:
with (Math){
x = cos(3 * PI) + sin (LN10)
y = tan(14 * E)
}