公司设计一个网站_东莞建设企业网站_温州seo_常德seo <script>/**** @param id 传入元素的id* @returns {HTMLElement | null} 返回标签对象,方便获取元素*/function my$(id) {return document.getElementById(id);}//获取各元素,方便操作var box=my$("box");var inner=box.children[0];var ulObj=inner.children[0];var list=ulObj.children;var olObj=inner.children[1];var arr=my$("arr");var imgWidth=inner.offsetWidth;var right=my$("right");var pic=0;//根据li个数,创建小按钮for(var i=0;i<list.length;i++){var liObj=document.createElement("li");olObj.appendChild(liObj);liObj.innerText=(i+1);liObj.setAttribute("index",i);//为按钮注册mouseover事件liObj.οnmοuseοver=function () {//先清除所有按钮的样式for (var j=0;j<olObj.children.length;j++){olObj.children[j].removeAttribute("class");}this.className="current";pic=this.getAttribute("index");animate(ulObj,-pic*imgWidth);}}//设置ol中第一个li有背景颜色olObj.children[0].className = "current";//克隆一个ul中第一个li,加入到ul中的最后=====克隆ulObj.appendChild(ulObj.children[0].cloneNode(true));var timeId=setInterval(onmouseclickHandle,1000);//左右焦点实现点击切换图片功能box.οnmοuseοver=function () {arr.style.display="block";clearInterval(timeId);};box.οnmοuseοut=function () {arr.style.display="none";timeId=setInterval(onmouseclickHandle,1000);};right.οnclick=onmouseclickHandle;function onmouseclickHandle() {//如果pic的值是5,恰巧是ul中li的个数-1的值,此时页面显示第六个图片,而用户会认为这是第一个图,//所以,如果用户再次点击按钮,用户应该看到第二个图片if (pic == list.length - 1) {//如何从第6个图,跳转到第一个图pic = 0;//先设置pic=0ulObj.style.left = 0 + "px";//把ul的位置还原成开始的默认位置}pic++;//立刻设置pic加1,那么此时用户就会看到第二个图片了animate(ulObj, -pic * imgWidth);//pic从0的值加1之后,pic的值是1,然后ul移动出去一个图片//如果pic==5说明,此时显示第6个图(内容是第一张图片),第一个小按钮有颜色,if (pic == list.length - 1) {//第五个按钮颜色干掉olObj.children[olObj.children.length - 1].className = "";//第一个按钮颜色设置上olObj.children[0].className = "current";} else {//干掉所有的小按钮的背景颜色for (var i = 0; i < olObj.children.length; i++) {olObj.children[i].removeAttribute("class");}olObj.children[pic].className = "current";}}left.οnclick=function () {if (pic==0){pic=list.length-1;ulObj.style.left=-pic*imgWidth+"px";}pic--;animate(ulObj,-pic*imgWidth);for (var i = 0; i < olObj.children.length; i++) {olObj.children[i].removeAttribute("class");}//当前的pic索引对应的按钮设置颜色olObj.children[pic].className = "current";};//设置任意的一个元素,移动到指定的目标位置function animate(element, target) {clearInterval(element.timeId);//定时器的id值存储到对象的一个属性中element.timeId = setInterval(function () {//获取元素的当前的位置,数字类型var current = element.offsetLeft;//每次移动的距离var step = 10;step = current < target ? step : -step;//当前移动到位置current += step;if (Math.abs(current - target) > Math.abs(step)) {element.style.left = current + "px";} else {//清理定时器clearInterval(element.timeId);//直接到达目标element.style.left = target + "px";}}, 10);}">

武汉专业建站

网站建设入门、手机软件开发工具、永久使用、不限域名、游戏软件开发

北京网页设计?

公司设计一个网站_东莞建设企业网站_温州seo_常德seo

              document.form1.checkcode.focus();

小程序后端开发长春网站建设公司长沙建站公司网站建设找哪家公司好html5开发手机app广州 网站建设德阳seo软件二次开发汕头网站建设河南app软件开发上海建站网商丘网站优化阳江seo重庆网站制作公司 建设 网站凯里网站开发做网站东莞网站建设教程视频鄂州网站制作app开发公司前十名手机软件开发工具郑州安卓app开发快速建站公司广东网站制作公司web应用开发网站开发培训邵阳seooa软件开发公司宁乡网站建设临沂企业建站定制建站网站建设

猜你喜欢