Ashura: Größe verändern

Beitrag lesen

Hallo Perro.

<html>
<head>
  <script type="text/javascript">
function bla(){
     document.getElementById("ddiv").style.height = "600px";
     document.getElementById("ddiv").style.width = "600px";
}
  </script>
</head>
<body>
  <form name="Testform">
    <div id="ddiv" onclick="bla()" style="height:400px; width:400px; background-color:#cccccc">
    </div>
  </form>
</body>
</html>

Mein Vorschlag:

<head>  
<title>Foo</title>  
<script type="text/javascript">  
  
  [code lang=javascript]window.onload = function() {  
  
    document.getElementById('ddiv').onclick = function() {  
  
      this.style.height = '600px';  
      this.style.width = '600px';  
  
    };  
  
  };

</script>
</head>
<body>
  <div id="ddiv" style="height:400px; width:400px; background-color:#cccccc">Bar</div>
</body>[/code]

Oder noch besser in klassenbasierter Fassung:

<head>  
<title>Foo</title>  
<style type="text/css">  
  [code lang=css]#ddiv {  
    background-color:#ccc;  
    height:400px;  
    width:400px;  
  }  
  .groesser {  
    height:600px;  
    width:600px;  
  }

</style>
<script type="text/javascript">

~~~javascript window.onload = function() {

document.getElementById('ddiv').onclick = function() {

this.className = 'groesser';

};

};

  
</script>  
</head>  
<body>  
  <div id="ddiv">Bar</div>  
</body>[/code]  
  
  
Einen schönen Montag noch.  
  
Gruß, Ashura  

-- 
sh:( fo:} ch:? rl:( br: n4:~ ie:{ mo:| va:) de:> zu:} fl:( ss:) ls:[ js:|  
„It is required that HTML be a common language between all platforms. This implies no device-specific markup, or anything which requires control over fonts or colors, for example. This is in keeping with the SGML ideal.“  
[[HTML Design Constraints: Logical Markup](http://www.w3.org/History/19921103-hypertext/hypertext/WWW/MarkUp/HTMLConstraints.html)]