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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2009
    Posts
    152
    Thanks
    8
    Thanked 0 Times in 0 Posts

    why the javascript toggle code doesn't work?

    I have added the Prototype library to my site, then add the following code. but when i click the span, the ul content is not hidden. the link href still work.

    Code:
    Event.observe(window, 'load', function() {
        Event.observe('.block-category li.parent span', 'click', function(e){
            $('.block-category li.parent ul').toggle();
            e.preventDefault();
    
        });
    });
    html:

    Code:
        <div class="block block-category">
        <li class="level-top  parent">
        <a href="example.com/...."><span>text one</span></a>
        <ul>
        <li><a><span>....</span></a></li>
        <li><a><span>....</span></a></li>
        <li><a><span>....</span></a></li>
        <li><a><span>....</span></a></li>
        </ul>
        </li>
    
        <li class="level-top"><a href="..."><span>....</span></a></li>
    
    
      <li class="level-top  parent">
        <a href="example.com/...."><span>text one</span></a>
        <ul>
        <li><a><span>....</span></a></li>
    
        </ul>
        </li>
      <li class="level-top  parent">
        <a href="example.com/...."><span>text one</span></a>
        <ul>
        <li><a><span>....</span></a></li>
        <li><a><span>....</span></a></li>
        </ul>
        </li>
        </div>
    thank you.

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,607
    Thanks
    6
    Thanked 997 Times in 970 Posts
    I’m not very familiar with prototype but somehow it looks to me as if you are mixing prototype and jQuery. You can’t do that.


  •  

    Posting Permissions

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