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
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    write inside a div

    hey ppl. i am new here. looks like i will do some Js for years
    i have a div called "farmacias" inside the content div
    i want to write something in the div but this is not working
    document.getElementById("farmacias").innerHTML='ola'
    anyone knows why?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,015
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    Works for me.

    Code:
    <div id = "container">
    <div id = "farmacias">
    </div>
    </div>
    <script type = "text/javascript">
    document.getElementById("farmacias").innerHTML='ola'
    </script>
    Are you sure that the <div> exists at the time the script executes?


    You were so far up Jim's behind, you couldn't see the wood for the trees. - Presenter BBC1

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Posting Permissions

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