style attributes are easily applicable to javascript code.
object.style.styleattribute
There is one basic rule you have to follow that is: if there is two name in style attribute like margin-left etc. write the first name(name before hyphen) as it is while the first letter of second name should be capital so:
margin-left = marginLeft
margin-top = marginTop
backgorund-color = backgroundColor
but single word’s attribute shoud be write as it is.
color = color
Example:
-
<table border="0">
-
<tbody>
-
<tr>
-
<td id="style_class" style="width: 80px; height: 50px;"></td>
-
</tr>
-
</tbody></table>
-
<strong>Color:</strong>
-
-
<input onclick="getElementById(’style_class’).style.background=’red’" name="botton" type="button" value="Red" /> <input onclick="getElementById(’style_class’).style.background=’green’" name="botton" type="button" value="Green" /> <input onclick="getElementById(’style_class’).style.background=’blue’" name="botton" type="button" value="Blue" /
Color:
Post a Comment