Change HTML class attribute using javascript
Javascript :
.styleOther
{
font-size: 18px;
padding:14px 15px 14px 15px;
text-decoration: none;
color:#ffffff;
}
.styleOthertest
{
font-size: 10px;
padding:14px 15px 14px 15px;
text-decoration: none;
color:#00f000;
}
-->
</style>
<script language="javascript">
function ChangeMenuByMouseClick(cur)
{
if(cur==1)
{
document.getElementById("advanced").setAttribute('class', 'styleOthertest');
}
HTML body:
<table style="width: 960px; height: 43px;" border="0" cellpadding="0" cellspacing="0"><tbody>
<tr>
<td class="menubar">
<a id="advanced" class="styleOther" onclick="ChangeMenuByMouseClick(1)"><font face="Arial">ADVANCED</font></a>
</td>
</tr>
</tbody></table>
Conclusion:
Using this Method can chang the attribute of HTML code.
Reference:
0 意見:
張貼留言