点击事件通过ID导航

时间:2016-05-30 09:32:44

标签: javascript jquery html

我在网站上工作,我有2页index.html和product.html,在product.html中 我有2个具有不同ID的div元素,现在当我点击index.html中导航到product.html的锚标签时,它应该导航到在product.html中持有不同内容的特定ID需要帮助

In index.html page i have anchor tag  
<a href=products.html>Building</a>
<a href=products.html>Infrastructure</a>

在product.html页面中,我得到了2个div

 <div id=#Building>
<div class="container">
</div>
<div>

<div id=#Infrastructure>
<div class="container">
</div>
<div>

当我点击锚标签时,我应该导航到特定的ID,就像我点击基础设施锚标签一样,它应该直接导航到product.html基础设施div

1 个答案:

答案 0 :(得分:0)

只需将该ID添加到您的href即可。 喜欢product.html #divid

的index.html

var laltitude = CURRENT_USER_laltitude;
var longitude = CURRENT_USER_longitude;
var query = "select distance(latitude, longitude,"+laltitude+","+longitude+") as distance from users";

创建inedx.html和products.html文件并粘贴上面的代码。 它按预期工作。

相关问题