div's in innerHTML

Discussion in 'JavaScript' started by gabs, Mar 6, 2007.

  1. #1
    This is driving me crazy.. .

    ok I have a code using lightbox.js which is very cool and basically imports a page into a div with a grey.bg cool.. This work fine..

    It import the page into a DIV ..
    Not the problem I have is I wish to contorl a div within that div..
    
    <div id="dk">
    </div>
    <script language="JavaScript">
    document.getElementById("dk").innerHTML ="<div id=area2>ddddddl</div>";
    function clik(){
    document.getElementById("area2").innerHTML ="GOOD BYE";
    }
    </script>
    <a href="#" onClick="clik();">dkdkd</a>
    
    
    Code (markup):
    As you know or can see it doesn't work..

    But is there any work around ? Thanks
     
    gabs, Mar 6, 2007 IP
  2. eclips

    eclips Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The problem is that
    document.getElementById("dk").innerHTML ="<div id=area2>ddddddl</div>";
    Code (markup):
    is not getting executed and therefor not visible.

    
    <script language="JavaScript">
      function loadDiv() {    
        document.getElementById("dk").innerHTML ="<div id=area2>ddddddl</div>";
      }
      function clik(){
        document.getElementById("area2").innerHTML ="GOOD BYE";
      }
    </script>
    <div id="dk"></div>
    
    <body onload="loadDiv()">
    <a href="#" onClick="clik();">dkdkd</a>
    </body>
    
    Code (markup):
    That might be what you're looking for.
     
    eclips, Mar 6, 2007 IP
  3. gabs

    gabs Peon

    Messages:
    135
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That works witht he above code but not in lightbox div :(

    hmmmm ..
     
    gabs, Mar 7, 2007 IP