Template:Paris/Toggle

From 2008.igem.org

(Difference between revisions)
 
(31 intermediate revisions not shown)
Line 1: Line 1:
-
<html>
+
<div class="toggleswitch">{{{1}}} ↑</div>
-
<style>
+
<div class="toggled" style="margin: auto; width: {{{3|935px;}}}">
-
.clicker {
+
-
cursor:pointer;
+
-
color:blue;
+
-
font-weight: bold;
+
-
}
+
-
</style>
+
-
<script type="text/javascript">
+
-
function toggleNext(el) {
+
-
var next=el.nextSibling;
+
-
while(next.nodeType != 1) next=next.nextSibling;
+
-
next.style.display=((next.style.display=="none") ? "block" : "none");
+
-
}
+
-
function getElementsByTagAndClassName(tag,cname) {
+
 
-
var tags=document.getElementsByTagName(tag);
+
{|cellspacing="2" cellpadding="10" style="background: black;" width=100%
-
var cEls=new Array();
+
|-valign="top"
-
for (i=0; i<tags.length; i++) {
+
|style="background: white;"|
-
  var rE = new RegExp("(^|\s)" + cname + "(\s|$)");
+
{{:{{{2}}}}}
-
  if (rE.test(tags[i].className)) {
+
|}
-
  cEls.push(tags[i]);
+
</div>
-
  }
+
-
  }
+
-
return cEls;
+
-
}
+
-
function toggleNextByTagAndClassName(tag,cname) {
+
-
var ccn="clicker";
+
-
clickers=getElementsByTagAndClassName(tag,cname);
+
-
for (i=0; i<clickers.length; i++) {
+
-
  clickers[i].className+=" "+ccn;
+
-
  clickers[i].onclick=function() {toggleNext(this)}
+
-
  toggleNext(clickers[i]);
+
-
}
+
-
}
+
-
window.onload=function(){toggleNextByTagAndClassName('div','toggleswitch')}
+
-
</script>
+
-
<div class="toggleswitch">↓ {{1}} ↑</div>
+
-
<div></html>''test''<html></div>
+
-
</html>
+

Latest revision as of 23:26, 29 October 2008

↓ {{{1}}} ↑


{{:{{{2}}}}}