I'm trying to change the CSS of an HTML element dynamically...for that purpose i am using innerHTML.
The problem I'm facing is, maybe Mozilla remembers the innerHTML of a textarea on the first posting. So if the user edits the text in textarea, it fails to show new text and shows original text in textarea. In IE it works fine.
What's wrong with innerHTML and mozilla firefox ?
<html>
<head>
<title></title>
<script type="text/javascript">
function abc()
{
alert(document.getElementById("c").innerHTML);
}
</script>
</head>
<body>
<textarea id="c" onclick="abc()">hello...</textarea>
</body>
</html>
Regarding your requirement, why don't you just do:
document.getElementById("c").className = "myCSSClass";
because using innerHTML
to change the CSS class of an element seems pretty weird...