【发布时间】:2016-10-15 21:55:34
【问题描述】:
我想点击 site1 上指向 site2 的链接,如果点击了该链接,则该页面上的隐藏文本(此处为:text_1_toggle)应该是可见的。
附:我对这个话题很陌生..如果我不能马上理解你的答案,请原谅我:)
站点 1:
<html>
<head>
</head>
<body>
<a href="site2.htm#text_1_toggle">Click me!</a>
</body>
</html>
站点2:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="toggle.js"></script>
<style>
h4:hover
{
cursor: pointer;
cursor: hand;
}
#text_1_toggle
{
display: none;
}
</style>
</head>
<body>
<div id="site">
<h4 id="text_1">Text 1</h4>
<span id="text_1_toggle">
1 some text...
</span>
<h4 id="text_2">Text 2</h4>
<span id="text_2_toggle">
2 some text...
</span>
</div>
</body>
toggle.js
jQuery("#site").ready(function()
{
jQuery("#text_1").click(function()
{
jQuery("#text_1_toggle").toggle();
});
jQuery("#text_2").click(function()
{
jQuery("#text_2_toggle").toggle();
});
});
【问题讨论】:
标签: javascript jquery html