Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Change the style of an element using JS

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #24613
    bor003
    Member

    Hello!

    I have a question that will probably seem really simple but I don’t really no how to use JavaScript so have no idea…

    What i would like to do would be that when people click inside an input box to start typing, the hole div holding that box changes colour to something set buy me, this is the layout so far…
    ___________styling__________

    .normal
    {
    background-color:gray;
    }.focus
    {
    background-color:white;
    }
    #contactbox1{
    height: 100px;
    }
    ______styling_____________

    _____HTML____________
    <div id="contactbox1" class="normal">
    <input type="text" size="40" class="normal" onfocus="this.className=’focus’" onblur="this.className=’normal’" />
    </div>
    _____HTML___________
    That will change the colour of the input box… but I want to change background colour of the div="contactbox1" Any ideas?
    (Does anybody no a good place to learn lots of JavaScript from scratch… Videos would be good as I’m deferentially a visual learner, that’s why I love the CSS-Tricks videos on itunes!)
    Regards

    #56399
    apostrophe
    Participant
    #56400
    bor003
    Member

    Thanks for that! That will defiantly help (I need to learn this to be able to do a lots of things lol)! :-)

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.