Thursday, December 6, 2012

style.width

Properti style.width digunakan untuk menetapkan lebar area isi suatu elemen.

Sintaks:

obj.style.width: value;

Nilainya:

  • auto (default).
  • Length
  • inherit

Contoh:

<HTML> <HEAD> <TITLE>style.width</TITLE> <STYLE TYPE="text/css"> #mydiv { height: 200px; width: 200px; border: solid #000 1px; } </STYLE> <SCRIPT TYPE="text/javascript"> function changeWidth() { document.getElementById("mydiv").style.width = "500px"; } </SCRIPT> </HEAD> <BODY> <DIV ID="mydiv"></DIV> <BUTTON TYPE="button" ONCLICK="changeWidth()">Change width!</BUTTON> </BODY> </HTML>