D
Dr J R Stockton
I have a page containing
<style type="text/css"><!--
.POP { display: none; background: cyan; }
--></style>
<BODY onLoad="ShowPup('pup')">
<script type="text/javascript">
function ShowPup(Cls) { var J=0, Elems, Elem
Elems = document.getElementsByTagName("*")
while (Elem=Elems[J++]) if (Elem.className==Cls) {
Elem.style.background = "#eea" } }
function Togl(X) { X = document.getElementById(X).style
X.display = X.display=='none' ? 'block' : 'none' }
</script>
<p class=pup onClick="Togl('ZZ000')">
Click toggles source view (may need second click).
<span ID=ZZ000 class=POP>Explanation.</span></p>
and a couple of dozen similar paragraphs and H5 headings with class=pup
and different ZZ numbers. There are paragraphs and headings which are
not class=pup.
In every case the span will (or can) come at the end of the p or H
element.
ShowPup('pup') automatically colours the pup items with #eea.
ISTM that it should be possible to eliminate the IDs, using TOGL(this)
and getting the span by DOM methods.
ISTM that it should then be possible for ShowPup to set each span to
hidden cyan (instead of using POP), and to set each pup to have
onClick="TOGL(this)" and onMouseOver="this.style.cursor='hand'".
But how?
<style type="text/css"><!--
.POP { display: none; background: cyan; }
--></style>
<BODY onLoad="ShowPup('pup')">
<script type="text/javascript">
function ShowPup(Cls) { var J=0, Elems, Elem
Elems = document.getElementsByTagName("*")
while (Elem=Elems[J++]) if (Elem.className==Cls) {
Elem.style.background = "#eea" } }
function Togl(X) { X = document.getElementById(X).style
X.display = X.display=='none' ? 'block' : 'none' }
</script>
<p class=pup onClick="Togl('ZZ000')">
Click toggles source view (may need second click).
<span ID=ZZ000 class=POP>Explanation.</span></p>
and a couple of dozen similar paragraphs and H5 headings with class=pup
and different ZZ numbers. There are paragraphs and headings which are
not class=pup.
In every case the span will (or can) come at the end of the p or H
element.
ShowPup('pup') automatically colours the pup items with #eea.
ISTM that it should be possible to eliminate the IDs, using TOGL(this)
and getting the span by DOM methods.
ISTM that it should then be possible for ShowPup to set each span to
hidden cyan (instead of using POP), and to set each pup to have
onClick="TOGL(this)" and onMouseOver="this.style.cursor='hand'".
But how?