jQuery显示/隐藏 [英] jQuery show / hide

查看:84
本文介绍了jQuery显示/隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用jquery在另一页上显示/隐藏特定的 div吗?

Can i user jquery to show / hide a specific div on another page?

即我有Content.aspx,可以显示我们提供的不同计划的内容.

i.e. i have Content.aspx that shows content for different plans we offer.

在detail.asp上,我有一个更详细的页面,具有独特的div.

on detail.asp i have a more detailed page that hase unique divs.

<div id="detail-a">
     detailed content here for product A.
</div>

<div id="detail-b">
     detailed content here for product B.
</div>

我不希望显示隐藏框滚动以显示页面的其余详细内容... 如果一切都说得通...

i dont want the show hide box to scroll to show the rest of the page detailed content... if that all makes sense...

推荐答案

如果我正确阅读了此书,则希望在一页上链接以将用户转到第二页,并在第二页上显示或隐藏特定内容div取决于用户在首页上单击的链接.

If I am reading this correctly, you are wanting links on one page to send the user to a second page and, on that second page, show or hide specific divs dependent on which link the user clicked on the first page.

Contents.aspx

<a href="details.asp#detail-a">See Detail A</a>
<a href="details.asp#detail-b">See Detail B</a>

details.asp

<div id="detail-a">
  Data on Detail A
</div>
<div id="detail-b">
  Data on Detail B
</div>
<script type="text/javascript">
$( document ).ready( function(){
  /* If there is a Hash and the Hash is an ID on this page */
   if( document.location.hash && $( document.location.hash ) ) {
    /* Hide all the Detail DIVs */
     $( 'div[id^="detail-"]' ).not( document.location.hash ).hide();
    /* Show the Specified Detail DIV */
     $( document.location.hash ).show();
   }
} );
</script>

这篇关于jQuery显示/隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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