Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Senior Member kirman's Avatar
    Join Date
    May 2003
    Location
    UK England
    Posts
    765
    Member #
    1499
    Liked
    2 times
    i get my CSS & dhtml guide 2moz but i was wonduring is it possible to use css withing javascript ?

    if so can u show me an exaple..
    Dream like you'll live forever. Live like you're gonna die 2morrow!

  2.  

  3. #2
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    Code:
    <html>
    <head>
    <title>blah</title>
    <script type="text/javascript">
    function widthchange() {
    document.getElementById('div1').style.width = 200 + 'px';
    }
    </script>
    </head>
    <body>
    <div style="width: 100px; height: 100px; background-color: #dddddd"
    id="div1">
    Hello
    </div>
    </body>
    </html>
    JR

  4. #3
    Senior Member kirman's Avatar
    Join Date
    May 2003
    Location
    UK England
    Posts
    765
    Member #
    1499
    Liked
    2 times
    woz that do? lol ... and which parts are css? im a newbie to css... i gather its something to do with the style
    Dream like you'll live forever. Live like you're gonna die 2morrow!

  5. #4
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    Oops...

    I didn't put a link in to execute the function. It is meant to make the div 200 px wide.

    Code:
    <html>
    <head>
    <title>blah</title>
    <script type="text/javascript">
    function widthchange() {
    document.getElementById('div1').style.width = 200 + 'px';
    }
    </script>
    </head>
    <body>
    <div style="width: 100px; height: 100px; background-color: #dddddd"
    id="div1">
    Hello
    </div>
    <a href="javascript: widthchange()">Expand!</a>
    </body>
    </html>
    The CSS is contained in the style attribute in the div tag.
    JR

  6. #5
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    Also, take out the space in 'java script' in the link.
    JR


Remove Ads

Posting Permissions

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

Search tags for this page

javascript widthchange

Click on a term to search for related topics.
All times are GMT -6. The time now is 02:19 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com