i have a small problem in my code when i try to update the value in the variable “a” to class attribute of label tag. Can anyone help me out. here is my code
<html>
<head>
<style>
label.visible {visibility:visible}
label.hidden {visibility:hidden}
</style>
<script type="text/javascript">
var a;
function doset()
{
a="hidden";
alert(a);
return a;
}
</script>
</head>
<body>
<form>
<label class=visible>Hello</label>
<button onclick="doset()">v</button><br>
<label class=a>Hello1</label><br>
<label class=a>Hello2</label><br>
<label class=a>Hello3</label><br>
<label class=a>Hello4</label><br>
<label class=a>Hello5</label><br>
</form>
</body>
</html>
Here is the fiddle : http://jsfiddle.net/M8CXN/
class=aThis does not bind the class name to the javascript global variable
a; they are different things in different contexts.If you want to manipulate classes you must do so via the DOM. The simplest way is to use a container;
and
called with