www.webdeveloper.com
Results 1 to 2 of 2

Thread: This MUST be an easy fix...?

Hybrid View

  1. #1
    Join Date
    Aug 2011
    Posts
    18

    This MUST be an easy fix...?

    Hi--

    I am using the following js to click on divA to fade out divB, and then click on divA again to fade in divB. It works the first time, but not the rest.

    My apologies for the terrible script (I know nothing about js), but could someone help me fix this? MANY THANKS FOR ANY HELP!

    $(document).ready(function(){
    $('#divA').click(function() {
    $('#divB').fadeOut(500, function() {
    $('#divA').click(function() {
    $('#divB').fadeIn(500);
    });
    });
    }); });

  2. #2
    Join Date
    Dec 2012
    Location
    Prague, Czech Republic
    Posts
    7
    Very easy ... take a look at the following.


    <!DOCTYPE html>
    <html>
    <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <meta charset=utf-8 />
    <title>JS Bin</title>

    <style>
    #divB {
    display: none;
    }
    </style>

    <script type="text/javascript">
    $(document).ready( function() {
    $('#divA').click(function() {
    $('#divB').fadeToggle("slow", "linear");
    });
    });
    </script>
    </head>
    <body>
    <button id="divA">Toggle Click</button>

    <div id="divB">
    <p>This is the text for this content</p>
    </div>

    </body>
    </html>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles