Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    4,753
    Tokens
    1,860
    Habbo
    ,Alpha,

    Latest Awards:

    Default Javascript assistance

    Hi,

    I am trying to learn some JS for a project I'm working on and I have a couple of questions-

    getElementById


    In the css, If I use .font for example to style a P tag then the getelement by ID works fine however when I use #divone the getelementbyid doesn't work is there a reason for this - also:

    do you need to do:

    <div class="name" id="divone">

    for the getelementbyid to work because I was under the impression the ID was the name of the css (for example .font) the id is font?

    Thanks!

  2. #2
    Join Date
    Dec 2007
    Location
    Manchester
    Posts
    2,236
    Tokens
    118
    Habbo
    hamheyelliot

    Latest Awards:

    Default

    CSS classes have a dot in front (like .font for example)

    Whereas IDs are those that are styled with hashtags (#font)

    What ID have you set the getElement to find?

  3. #3
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    4,753
    Tokens
    1,860
    Habbo
    ,Alpha,

    Latest Awards:

    Default

    Quote Originally Posted by hamheyelliot View Post
    CSS classes have a dot in front (like .font for example)

    Whereas IDs are those that are styled with hashtags (#font)

    What ID have you set the getElement to find?
    If I have a css class (.myfont) and then use getelementbyid('myfont').style.color = ... I can recolour the text however...

    If I have a css id (#mydiv) and then use getelementbyid('mydiv').style.display = ... I can't change the visibility of the div


    I am working up to a navigation menu using css but I need to start by learning ^

  4. #4
    Join Date
    Dec 2007
    Location
    Manchester
    Posts
    2,236
    Tokens
    118
    Habbo
    hamheyelliot

    Latest Awards:

    Default

    Quote Originally Posted by Lee View Post
    If I have a css class (.myfont) and then use getelementbyid('myfont').style.color = ... I can recolour the text however...

    If I have a css id (#mydiv) and then use getelementbyid('mydiv').style.display = ... I can't change the visibility of the div


    I am working up to a navigation menu using css but I need to start by learning ^
    Okay, what does your HTML look like? Could be the root of the problem.

  5. #5
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    4,753
    Tokens
    1,860
    Habbo
    ,Alpha,

    Latest Awards:

    Default

    Quote Originally Posted by hamheyelliot View Post
    Okay, what does your HTML look like? Could be the root of the problem.
    Is there any way we could talk about this using msn (and possibly teamviewer)?

    Not right now but throughout the next week maybe

    -Lee

  6. #6
    Join Date
    Dec 2007
    Location
    Manchester
    Posts
    2,236
    Tokens
    118
    Habbo
    hamheyelliot

    Latest Awards:

    Default

    Quote Originally Posted by Lee View Post
    Is there any way we could talk about this using msn (and possibly teamviewer)?

    Not right now but throughout the next week maybe

    -Lee
    Yeah, my MSN is [email protected] if you want to add me on there. Would probably be easier to just see the entirety of the code after all.

  7. #7
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    You aren't setting the id attribute correctly. If you were it would work.

    element
    #id
    .class

    <div id="theid" class="theclass">

    would be:
    element = document.getElementsByTagName('div')
    id = document.getElementById('theid')
    class = document.getElementsByClassName('theclass')

    You don't include # in the id tag on the actual html. If you are doing so, remove it, if you're not doing that and you use my exact bit of html and javascript and it's still broken, re-install your browser as it is broken.


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

Posting Permissions

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