zoukankan      html  css  js  c++  java
  • jquery slideUp()

    http://api.jquery.com/click/


    Re: Creating a toggle (show and hide) for hyperlink click

    作者: 
     在 01-Sep-2009 06:56 AM.
      在  Using jQuery 
    Hi,

    I wish to use Jquery. I am a newbie. I have a hyperlink and when a user clicks that I wish to toggel ie. show or hide the text . This is what I have so far.

    <a href="#" onclick="toggle("hidden");">FAQ</a>

    <div id="hidden">
    Some Questions
    Some Answers
    </div>

    <script type="text/javascript" language="javascript">
    function toggle(id) {
    var state = document.getElementById(id).style.display;
    if (state == 'block')
    {
    document.getElementById(id).style.display = 'none';
    }
    else
    {
    document.getElementById(id).style.display = 'block';
    }
    }
    </script>

    Any inputs would be greatly appreciated.
    • 无状态
    • 需要更多信息
    • 已回答
    • 等待中
    Have a look at this. Will do the trick for you.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
       <title>Tyde's test lab</title>
       
       <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
       <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
       
       <script type="text/javascript">
          $(function() {
             $('a#faq').click(function() {
                $('div#hidden').toggle();
                return false;
             });
          });   
       </script>
    </head>
    <body>
    <a href="#" id="faq">F A Q</a><br />
    <br />
    <div id="hidden">
    Some Questions
    Some Answers
    </div>

    </body>
    </html>




  • 相关阅读:
    操作系统
    Typora
    C++
    linux sftp 和scp 运用
    python GIL锁与多cpu
    django model 高级进阶
    django template 模板
    django view 视图控制之数据返回的视图函数
    django 创建管理员用户
    jango 模型管理数据model入门
  • 原文地址:https://www.cnblogs.com/lexus/p/1847594.html
Copyright © 2011-2022 走看看