SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Location
    England, UK
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    nested lists showing 'open' on page load

    Hi Everyone.

    I am a complete novice at javascript.

    I am building a site where i am using some nested lists which I want to show when clicking ther parent li and then disapear when clicking it again.

    the problem I am having is when the page initially loads or is refreshed it shows all the nested lists 'opened'

    here is the link:

    http://www.hullcomedy.co.uk/hullcomedy/getinvolved.htm

    its the top 2 links in the main content area.

    I appreciate this may have been covered before but really dont have time at the minute to search or read through info - deadlines looming...

    Any help would be great!

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The show function is not defined yet you set it to be called via window.onload.

    You've nested the lists incorrectly. Only <li>s may be children of the <ul>s and <ol>s. The inner <ul>s need to be nested in the <li>s of the parent list. Will the inner lists really be marking up lists?

    I am concerned that your code is not following JavaScript Best Practices. I strongly recommend you read up on them.

    Don't forget to make sure that the (X)HTML and CSS code you write is valid.
    http://validator.w3.org/
    http://jigsaw.w3.org/css-validator/
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Location
    England, UK
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the reply

    to be honest i was looking for a quick fix to what the client was asking for, the whole use of the nested list was totally inappropriate and not good use of semantic markup.

    I will take another look at that page when i have done the other 20...i think i will just have the links open in a new window

    once i have got all the pages in place part of my final checklist includes validating the xhtml and css

  4. #4
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could do that, or you could do something like this.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Location
    England, UK
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that, this is exactly the kind of thing i was looking for

    I have just implemented it on that page:
    http://www.hullcomedy.co.uk/hullcomedy/getinvolvedj.htm

    I will show the client tomorrow, I suppose the final decision will depend how much text they want to appear, if its too much I will just use a new page.
    Last edited by dreadster; Apr 19, 2007 at 07:08.


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
  •