Created
September 9, 2011 04:40
-
-
Save varnie/1205506 to your computer and use it in GitHub Desktop.
an example of changing a style of td using prototype js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>getElementById example#3</title> | |
<style> | |
table .c { color: red } | |
.a.c {color: green} | |
</style> | |
<script type="text/javascript" src="http://www.google.com/jsapi"></script> | |
<script type="text/javascript">google.load("prototype", "1.6.0.2");</script> | |
<script type="text/javascript"> | |
function changeStyle(theId){ | |
var cell = $$("#"+theId+" tr td:first"); | |
cell.each(function(c){ | |
c.toggleClassName("a"); | |
}); | |
} | |
Event.observe(window, 'load', function() { | |
$("b").observe("click", function() { changeStyle("t"); }); | |
}); | |
</script> | |
</head> | |
<body> | |
<table id="t"> | |
<tr> | |
<td class="c">Текст</td> | |
</tr> | |
</table> | |
<button id="b">change color</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment