www.webdeveloper.com
Results 1 to 3 of 3

Thread: Conditional Hiding

  1. #1
    Join Date
    Jan 2013
    Posts
    3

    Conditional Hiding

    Hi everyone;

    At the pages of my site I have a module which shows related articles belonging to same category. If the category contains only one article, I only have the header.
    I have this code;
    Code:
    <script type="text/javascript">
    onload=function(){
    if(document.getElementById('documentlist').getElementsByTagName('li').length < 1){document.getElementById('moduleheader').style.display = 'none';}}
    		</script>
    What I trying to do is to hide "documentheader" div if <ul id="documentlist"> has less than 1 li tagged document. What is wrong with that, or what can I do other than this codding?

  2. #2
    Join Date
    Feb 2011
    Posts
    231
    Hi,
    Try adding "window." before "onload".
    Code:
    window.onload = function() {
      if(document.getElementById('documentlist').getElementsByTagName('li').length < 1) {
        document.getElementById('moduleheader').style.display = 'none';
      }
    }

  3. #3
    Join Date
    Jan 2013
    Posts
    3
    I'll try as soon as possible this, and result will be written here. Thank you.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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