Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: text is gone

  1. #1
    Regular Coder nolvorite's Avatar
    Join Date
    Dec 2006
    Posts
    176
    Thanks
    7
    Thanked 0 Times in 0 Posts

    text is gone

    So i'm trying to make a menu but i'm failing tragically atm
    Whenever you hover an <a> inside #submenu .mp1, 2 and 3 is supposed to be wrapped inside <a> and when it hovers out it will be all gone. I managed to take out the element but the text is gone.
    it's every <a> at #submenu http://nolvorite.cu.cc/ (not a legit website in case you think i'm advertising)
    Code:
    <!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>Index</title>
    <link rel="stylesheet" type="text/css" href="edits.css" />      
    <script type="text/javascript" src="jquery-1.9.1.min.js"></script>
    </head><body>
    <div id="header">
    
    <div id="logo"><a href=""></a>
    </div>  
    
    <div id="submenu">
    <a href="">Link 1</a>       
    <a href="">Link 2</a>
    <a href="">Link 3</a>
    </div> 
    
    
    
    </div>         <script src="modulation.js"></script>
    </body></html>
    modulation.js
    Code:
    $("#submenu").wrapInner("<div id='sub1'><div id='sub2'><div id='spacein'></div></div></div>");
    $("#submenu a").each(function(){
    $(this).hover(function(){
    $(this).wrapInner("<div class='mp1'><div class='mp2'><div class='mp3'></div></div></div>");
    
    },function(){                                              
    $(this).children().remove().end().text($(this).text());
    }
    );   
    })
    Last edited by nolvorite; 04-16-2013 at 12:09 AM.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,484
    Thanks
    23
    Thanked 636 Times in 635 Posts
    I have dome my menus based on this page. It has never let me down
    http://www.htmldog.com/articles/suckerfish/dropdowns/
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    Regular Coder nolvorite's Avatar
    Join Date
    Dec 2006
    Posts
    176
    Thanks
    7
    Thanked 0 Times in 0 Posts
    not really concerned about dropdowns right now but more with DOM manipulation
    thanks for the link tho

  • #4
    Regular Coder nolvorite's Avatar
    Join Date
    Dec 2006
    Posts
    176
    Thanks
    7
    Thanked 0 Times in 0 Posts
    bumping? need help on this guize

  • #5
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,798
    Thanks
    6
    Thanked 1,023 Times in 996 Posts
    First of all, hover() is deprecated in the latest jQuery, you should rather use .on('mouseenter mouseleave', function() {…}) (for simple toggles) or the single chained functions .mouseenter() and .mouseleave() (or their .on(…) equivalents) instead.

    Then you need to retreive and append the text node before you remove the element. So, on moue out/leave try this:
    Code:
    $(this).prepend($(this).text()).children().remove();
    Last edited by VIPStephan; 04-18-2013 at 12:40 AM.


  •  

    Posting Permissions

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