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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Unhappy Simple Javascript Question (newbie)

    I am javascript retarded and i was just trying what i thought was a simple learning exersice but i can't get it to work heres what i have:
    <html>
    <head>
    </head>
    <body>
    <p id="test"> What am i doing wrong?</p>
    <script>
    var try=document.getElementById('test').innerHTML;
    alert(try);
    </script>
    </body>
    </html>
    all i'm trying to do is use the getelement to take the html from the paragraph and then display it in an alert just to try and learn the script; my syntax is probably wrong and probably much of the rest is too, anyway i appreciate any help from posters
    Last edited by Jhel; 08-22-2008 at 10:59 PM.

  • #2
    Regular Coder
    Join Date
    Sep 2007
    Location
    AZ, USA
    Posts
    685
    Thanks
    6
    Thanked 46 Times in 46 Posts
    Try is a reserved name. Use a different variable name.

    Code:
    <html>
    <head>
    </head>
    <body>
    <p id="test"> What am i doing wrong?</p>
    <script type="text/javascript">
    var try1=document.getElementById('test').innerHTML;
    alert(try1);
    </script>
    </body>
    </html>

  • Users who have thanked binaryWeapon for this post:

    Jhel (08-23-2008)

  • #3
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thumbs up

    thank you I'm new to the syntax and assigned characters


  •  

    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
    •