按ID转到HTML格式的div [英] Go to div in HTML by id

查看:105
本文介绍了按ID转到HTML格式的div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

如果我必须跳到同一页面的某个div然后我用

7



但是这里Section_7是Div的名字现在问题是我可以通过Id的div访问相同的div吗?如果是的话怎么样?请给我回答

解决方案

以完全相同的方式 - 如果你的div的id为(例如)section7,那么:

 <   a     href   = #section7 > 第7节<   / a  >  



将滚动页面,以便div的开头位于顶部页面(假设页面足够长)。


多年来你不需要锚点。

你可以简单地使用任何id页面作为锚点。

 <   div     id   =  id152 >  blabla <   / div  >  
...
..
< a href = http://yoursite.com/yourpage.html#id152 > < / a >


hello friends ,
if i have to jump to some div on the same page then i uses
Section 7

but here Section_7 is the name of Div now the question is can i access the same div by Id of div ? if yes then how ? please give me answer

解决方案

In exactly the same way - if your div has an id of (for example) "section7", then:

<a href="#section7">Section 7</a>


Will scroll the page so that the start of the div will be at the top of the page (assuming the page is long enough).


As for some years you don't need anchors.
You can simply use any id on a page as anchor.

<div id="id152">blabla</div>
...
..
<a href="http://yoursite.com/yourpage.html#id152"></a>


这篇关于按ID转到HTML格式的div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆