首页 > Web开发 > 详细

<a>标签 href属性值为#或以#开头的意思

时间:2015-04-25 09:24:07      阅读:271      评论:0      收藏:0      [点我收藏+]

比如说当一个页面里面有一个这样的标签   <a name="hello" >name为hello的锚点</a>

这个<a>标签可以称之为一个"锚点"


当然页面上还有这两个超链接<a>标签。

<a href="#hello">回到name为hello的锚点</a><br>
<a href="#">回到顶层</a>

好那么现在开始讲解 : href="#hello" 的时该<a>标签可以回到页面内一个name属性为hello的一个<a>标签(name="hello")。

当href="#"的时候该超链接<a>标签可以回到页面顶端。

下面来看实际的代码来体验下效果。

html 代码:

<span style="font-size:18px;"><div id="area1"></div>
<a name="hello" >name为hello的锚点</a>
<div id="area2"></div>
<a href="#hello">回到name为hello的锚点</a><br>
<a href="#">回到顶层</a></span>

javascript脚本段:

<span style="font-size:18px;"><script type="text/javascript">

	$(document).ready(function()
			{
						for(var i = 0 ; i < 20 ; i++)
						{
								$("#area1").append("<p>helloworld " + i + "</p>");
						}

						for(var i = 0 ; i < 40 ; i++)
						{
								$("#area2").append("<p>helloworld " + i + "</p>");
						}
			});

</script></span>



<a>标签 href属性值为#或以#开头的意思

原文:http://blog.csdn.net/u013803262/article/details/45267459

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!