Results 1 to 5 of 5

Thread: Toggle image with text.

  1. #1
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Toggle image with text.

    Please help me i am unable to toggle the image to get the text behind that when mouseover on the image..

    HTML Code:
    <html>
    <head>
    
    <script src="script1/jquery-1.7.2.js" type="text/javascript"></script>
    <script>
    $(document).ready(function() {
      $('.nav-toggle').mouseover(function(){
        //get collapse content selector
        var collapse_content_selector = $(this).attr('href');
        //make the collapse content to be shown or hide
        var toggle_switch = $(this);
        $(collapse_content_selector).toggle(function(){
          if($(this).css('display')=='none'){
          }
        });
      });
      $('.nav-toggle').mouseout(function(){
        //get collapse content selector
        var collapse_content_selector = $(this).attr('href');
        //make the collapse content to be shown or hide
        var toggle_switch = $(this);
        $(collapse_content_selector).toggle(function(){
          if($(this).css('display')=='none'){
          }
        });
      });
    });
    </script>
    </head>
    <body>
    <a href="sole.html" class="nav-toggle"><img src="images/12.jpg" width="298" height="59" alt="image">
    
    <div id="collapse1" style="display:none">my text that is revealed is this section.....</div>
    </body>
    </html>
    Last edited by traq; 11-14-2012 at 04:56 PM. Reason: formatting / please indent your code & use the forum's BBCode tags

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Two things:

    1) you didn't close your <a> tag.

    2) your anchor's href points to another page, while the script expects it to be a selector for the content you want to show.

    working example

  3. #3
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by traq View Post
    Two things:

    1) you didn't close your <a> tag.

    2) your anchor's href points to another page, while the script expects it to be a selector for the content you want to show.

    working example
    I had done that but it is not directing to another page .

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    As traq says, the script is to reveal content. The function isn't needed if you just want to go to another page so just use a standard anchor tag without the nab-toggle class.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  5. #5
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    right - so, to clarify, what do you want to accomplish?

Similar Threads

  1. Toggle Text in Textarea
    By theflyingminstrel in forum JavaScript
    Replies: 3
    Last Post: 07-12-2009, 08:15 PM
  2. replace images with text to toggle hidden div
    By dannyboy83 in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 03-17-2009, 04:13 PM
  3. Replies: 2
    Last Post: 11-01-2008, 03:58 AM
  4. Java Script Toggle text
    By Mehok in forum JavaScript
    Replies: 5
    Last Post: 10-04-2006, 01:19 PM
  5. Anyone know a JavaScript to toggle text
    By Dale in forum JavaScript
    Replies: 3
    Last Post: 09-15-2006, 12:52 AM

Bookmarks

Posting Permissions

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