www.webdeveloper.com
Results 1 to 2 of 2

Thread: Calling Function inside DIV from Parent

  1. #1
    Join Date
    Jul 2009
    Posts
    8

    Calling Function inside DIV from Parent

    Hello,
    Can someone tell me the proper way to execute helloThere() from the parent function getHelloThere()? This code is not working for me...

    index.html
    --------------
    <script>
    function getHelloThere()
    {
    document.getElementById('div1').helloThere();
    }
    </script>

    <div id="div1">
    <script>
    function helloThere()
    {
    alert('Yahtzee');
    }
    </script>
    </div>

    All suggestions are appreciated.

  2. #2
    Join Date
    Jan 2011
    Location
    United Kingdom, London
    Posts
    117
    Code:
    <head>
    <script>
    function getHelloThere()
    {
    helloThere();
    }
    </script>
    </head>
    
    <body>
    <div id="div1">
    <script>
    function helloThere()
    {
    alert('Yahtzee');
    }
    </script>
    </div>
    </body>
    </html>
    now you can assign function getHelloThere to button or event but.... why would you like to separate those function? that makes no sense -.-
    Javascript, jQuery / Prototype & PHP expert ready to complete your work on Freelancer.co.uk - Hire Me at https://www.freelancer.co.uk/users/1...&action=hireme

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