Git Product home page Git Product logo

lee's People

Contributors

totoro325 avatar

Watchers

 avatar

lee's Issues

学习javascript---选项卡

说明:这个范例来自大神 Ferris

学习遇到的困难:
1:javascript权威手册看了一页就看不下去了。
2:各种算法语法看了就痛苦

看到网上的例子感觉很有意思。只好循序渐进的学习了。

	<script>
		window.onload = function() //页面载入完成后执行
		{
			var oLi = document.getElementById("tab").getElementsByTagName("li"); //获取id为tab的li的存储到变量oli
			var oUl = document.getElementById("content").getElementsByTagName("ul"); //获取id为content里的ul存储到oUl

			for (var i = 0; i < oLi.length; i++) //遍历li
			{
				oLi[i].index = i; //定义索引
				oLi[i].onclick = function() //当tab里的li 点击的时候执行
				{
					for (var n = 0; n < oLi.length; n++) oLi[n].className = ""; //定义变量n,遍历tab的li并清空样式
					this.className = "current"; //当前的样式赋值为current;
					for (var n = 0; n < oUl.length; n++) oUl[n].style.display = "none"; //遍历ul,赋值隐藏。
					oUl[this.index].style.display = "block" //当前的UL显示。
					return false;
				}

			}
		}
	</script>

这样就可以实现选项卡了。
注释是我自己的理解,感觉入门还是很友好的。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.